Skip to content

feat(debugger): implement capture expressions#7431

Open
watson wants to merge 1 commit intomasterfrom
watson/DEBUG-5011/capture-expressions
Open

feat(debugger): implement capture expressions#7431
watson wants to merge 1 commit intomasterfrom
watson/DEBUG-5011/capture-expressions

Conversation

@watson
Copy link
Collaborator

@watson watson commented Feb 4, 2026

What does this PR do?

This PR implements capture expressions for Live Debugger/Dynamic Instrumentation log probes, providing an alternative to full snapshot capture. Instead of serializing entire object graphs, users can now define specific expressions to capture, giving them precise control over what data gets collected and addressing the 1MB Event Platform payload limit.

Motivation

Log probes currently face a significant limitation: when captureSnapshot: true is enabled, the debugger serializes entire object graphs. Even with depth restrictions in place, this approach might hit the 1MB Event Platform limit. The problem becomes frustrating when users need a specific piece of deeply nested data, increasing the capture depth to reach that value inadvertently captures large amounts of uninteresting data from other parts of the object graph.

Capture expressions solve this by letting users define exactly which data they need. When captureExpressions is defined on a probe, the debugger switches to expression-only mode, evaluating and serializing only the specified expressions. Each expression can optionally override the default capture limits for depth, collection size, field count, and string length, providing fine-grained control over what gets captured.

The implementation includes robust error handling that distinguishes between two types of failures. Evaluation errors, like ReferenceError for undefined variables, are expected JavaScript errors that get reported per-expression while allowing other expressions to continue. Fatal errors, such as protocol failures, indicate something more serious has gone wrong, so the entire capture expressions feature is disabled for that probe until the probe is re-applied, preventing repeated failures on every breakpoint hit.

Time budget enforcement remains a critical aspect of the debugger's performance profile: When capture expressions are being evaluated, the timeout applies across all expressions. If the time budget is exceeded, successfully evaluated expressions are included in the snapshot, while remaining unevaluated expressions appear with a notCapturedReason field indicating the timeout was reached. This ensures the snapshot structure remains predictable even when operating under time pressure.

Additional Notes

@github-actions
Copy link
Contributor

github-actions bot commented Feb 4, 2026

Overall package size

Self size: 4.57 MB
Deduped: 5.41 MB
No deduping: 5.41 MB

Dependency sizes | name | version | self size | total size | |------|---------|-----------|------------| | import-in-the-middle | 2.0.6 | 81.92 kB | 813.08 kB | | dc-polyfill | 0.1.10 | 26.73 kB | 26.73 kB |

🤖 This report was automatically generated by heaviest-objects-in-the-universe

@watson watson self-assigned this Feb 4, 2026
@watson watson added semver-minor debugger Dynamic Instrumentation & Live Debugger labels Feb 4, 2026
Copy link
Collaborator Author

watson commented Feb 4, 2026

This stack of pull requests is managed by Graphite. Learn more about stacking.

@pr-commenter
Copy link

pr-commenter bot commented Feb 4, 2026

Benchmarks

Benchmark execution time: 2026-02-04 10:08:50

Comparing candidate commit 90ae293 in PR branch watson/DEBUG-5011/capture-expressions with baseline commit 5e2f013 in branch master.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 226 metrics, 34 unstable metrics.

Add support for capturing specific expressions in log probes as an
alternative to full snapshot capture. This allows users to precisely
define which data they want to collect, addressing the 1MB Event
Platform payload limit issue.

When capture expressions are defined, only those expressions are
evaluated and serialized instead of capturing the entire object
graph of local variables, arguments, and fields. Each expression can
optionally override the default capture limits (depth, collection
size, field count, and string length).

The implementation distinguishes between transient evaluation errors
(like undefined variables) and fatal errors (like protocol failures),
allowing some expressions to succeed even when others fail. Fatal
errors disable capture expressions for the probe until it's
re-applied, preventing repeated failures.

Time budget enforcement is respected across all expressions. If the
timeout is reached while evaluating expressions, any remaining
unevaluated expressions are still included in the snapshot with a
notCapturedReason indicating the timeout was exceeded.
@watson watson force-pushed the watson/DEBUG-5011/capture-expressions branch from ea82eb7 to 90ae293 Compare February 4, 2026 10:00
@codecov
Copy link

codecov bot commented Feb 4, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.40%. Comparing base (5e2f013) to head (90ae293).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #7431   +/-   ##
=======================================
  Coverage   80.40%   80.40%           
=======================================
  Files         732      732           
  Lines       31050    31050           
=======================================
+ Hits        24965    24966    +1     
+ Misses       6085     6084    -1     
Flag Coverage Δ
aiguard-macos 39.07% <ø> (-0.11%) ⬇️
aiguard-ubuntu 39.11% <ø> (-0.11%) ⬇️
aiguard-windows 38.96% <ø> (-0.11%) ⬇️
apm-capabilities-tracing-macos 48.89% <ø> (ø)
apm-capabilities-tracing-ubuntu 48.89% <ø> (ø)
apm-capabilities-tracing-windows 48.62% <ø> (ø)
apm-integrations-child-process 38.56% <ø> (-0.11%) ⬇️
apm-integrations-couchbase-18 37.32% <ø> (-0.25%) ⬇️
apm-integrations-couchbase-eol 37.80% <ø> (-0.25%) ⬇️
apm-integrations-oracledb 37.99% <ø> (-0.10%) ⬇️
appsec-express 55.37% <ø> (-0.07%) ⬇️
appsec-fastify 51.99% <ø> (-0.08%) ⬇️
appsec-graphql 52.31% <ø> (-0.07%) ⬇️
appsec-kafka 44.63% <ø> (-0.09%) ⬇️
appsec-ldapjs 44.30% <ø> (-0.09%) ⬇️
appsec-lodash 43.98% <ø> (-0.09%) ⬇️
appsec-macos 58.48% <ø> (-0.07%) ⬇️
appsec-mongodb-core 49.07% <ø> (-0.20%) ⬇️
appsec-mongoose 49.87% <ø> (-0.09%) ⬇️
appsec-mysql 51.26% <ø> (-0.08%) ⬇️
appsec-node-serialize 43.49% <ø> (-0.09%) ⬇️
appsec-passport 48.10% <ø> (-0.09%) ⬇️
appsec-postgres 51.05% <ø> (-0.08%) ⬇️
appsec-sourcing 42.84% <ø> (-0.09%) ⬇️
appsec-template 43.66% <ø> (-0.09%) ⬇️
appsec-ubuntu 58.50% <ø> (-0.07%) ⬇️
appsec-windows 58.34% <ø> (-0.07%) ⬇️
instrumentations-instrumentation-bluebird 32.23% <ø> (-0.11%) ⬇️
instrumentations-instrumentation-body-parser 40.72% <ø> (-0.10%) ⬇️
instrumentations-instrumentation-child_process 37.87% <ø> (-0.11%) ⬇️
instrumentations-instrumentation-cookie-parser 34.50% <ø> (-0.10%) ⬇️
instrumentations-instrumentation-express 34.84% <ø> (-0.10%) ⬇️
instrumentations-instrumentation-express-mongo-sanitize 34.63% <ø> (-0.10%) ⬇️
instrumentations-instrumentation-express-session 40.40% <ø> (-0.10%) ⬇️
instrumentations-instrumentation-fs 31.83% <ø> (-0.11%) ⬇️
instrumentations-instrumentation-generic-pool 29.79% <ø> (ø)
instrumentations-instrumentation-http 39.61% <ø> (-0.10%) ⬇️
instrumentations-instrumentation-knex 32.24% <ø> (-0.11%) ⬇️
instrumentations-instrumentation-mongoose 33.61% <ø> (-0.10%) ⬇️
instrumentations-instrumentation-multer 40.46% <ø> (-0.10%) ⬇️
instrumentations-instrumentation-mysql2 38.26% <ø> (-0.11%) ⬇️
instrumentations-instrumentation-passport 40.76% <ø> (-0.10%) ⬇️
instrumentations-instrumentation-passport-http 40.73% <ø> (-0.10%) ⬇️
instrumentations-instrumentation-passport-local 40.73% <ø> (-0.10%) ⬇️
instrumentations-instrumentation-pg 37.78% <ø> (-0.11%) ⬇️
instrumentations-instrumentation-promise 32.16% <ø> (-0.11%) ⬇️
instrumentations-instrumentation-promise-js 32.17% <ø> (-0.11%) ⬇️
instrumentations-instrumentation-q 32.21% <ø> (-0.11%) ⬇️
instrumentations-instrumentation-url 32.13% <ø> (-0.11%) ⬇️
instrumentations-instrumentation-when 32.18% <ø> (-0.11%) ⬇️
llmobs-ai 41.40% <ø> (-0.10%) ⬇️
llmobs-anthropic 40.62% <ø> (-0.10%) ⬇️
llmobs-bedrock 39.51% <ø> (-0.09%) ⬇️
llmobs-google-genai 40.11% <ø> (-0.09%) ⬇️
llmobs-langchain 39.65% <ø> (-0.08%) ⬇️
llmobs-openai 44.45% <ø> (-0.09%) ⬇️
llmobs-vertex-ai 40.33% <ø> (-0.10%) ⬇️
platform-core 28.09% <ø> (ø)
platform-esbuild 31.49% <ø> (ø)
platform-instrumentations-misc 39.62% <ø> (ø)
platform-shimmer 34.83% <ø> (ø)
platform-unit-guardrails 30.37% <ø> (ø)
plugins-azure-event-hubs 22.64% <ø> (ø)
plugins-azure-service-bus 22.08% <ø> (ø)
plugins-bullmq 43.56% <ø> (-0.10%) ⬇️
plugins-cassandra 38.03% <ø> (-0.10%) ⬇️
plugins-cookie 23.69% <ø> (ø)
plugins-cookie-parser 23.50% <ø> (ø)
plugins-crypto 22.88% <ø> (ø)
plugins-dd-trace-api 38.38% <ø> (-0.11%) ⬇️
plugins-express-mongo-sanitize 23.67% <ø> (ø)
plugins-express-session 23.46% <ø> (ø)
plugins-fastify 42.52% <ø> (-0.10%) ⬇️
plugins-fetch 38.59% <ø> (-0.10%) ⬇️
plugins-fs 38.66% <ø> (-0.11%) ⬇️
plugins-generic-pool 22.68% <ø> (ø)
plugins-google-cloud-pubsub 45.70% <ø> (-0.12%) ⬇️
plugins-grpc 41.29% <ø> (-0.10%) ⬇️
plugins-handlebars 23.71% <ø> (ø)
plugins-hapi 40.42% <ø> (-0.10%) ⬇️
plugins-hono 40.62% <ø> (-0.10%) ⬇️
plugins-ioredis 38.46% <ø> (-0.11%) ⬇️
plugins-knex 23.51% <ø> (ø)
plugins-ldapjs 21.28% <ø> (ø)
plugins-limitd-client 32.53% <ø> (-0.11%) ⬇️
plugins-lodash 22.74% <ø> (ø)
plugins-mariadb 39.53% <ø> (-0.11%) ⬇️
plugins-memcached 38.19% <ø> (-0.11%) ⬇️
plugins-microgateway-core 39.43% <ø> (-0.10%) ⬇️
plugins-moleculer 40.83% <ø> (-0.10%) ⬇️
plugins-mongodb 39.54% <ø> (-0.10%) ⬇️
plugins-mongodb-core 39.12% <ø> (-0.10%) ⬇️
plugins-mongoose 39.17% <ø> (-0.10%) ⬇️
plugins-multer 23.46% <ø> (ø)
plugins-mysql 39.25% <ø> (-0.11%) ⬇️
plugins-mysql2 39.30% <ø> (-0.10%) ⬇️
plugins-node-serialize 23.73% <ø> (ø)
plugins-opensearch 37.87% <ø> (-0.10%) ⬇️
plugins-postgres 35.70% <ø> (-0.09%) ⬇️
plugins-process 22.88% <ø> (ø)
plugins-pug 23.69% <ø> (ø)
plugins-redis 38.78% <ø> (-0.11%) ⬇️
plugins-router 43.23% <ø> (-0.10%) ⬇️
plugins-sequelize 22.27% <ø> (ø)
plugins-test-and-upstream-amqp10 38.38% <ø> (-0.11%) ⬇️
plugins-test-and-upstream-amqplib 43.89% <ø> (-0.10%) ⬇️
plugins-test-and-upstream-apollo 39.32% <ø> (-0.09%) ⬇️
plugins-test-and-upstream-avsc 38.80% <ø> (-0.11%) ⬇️
plugins-test-and-upstream-bunyan 33.85% <ø> (-0.11%) ⬇️
plugins-test-and-upstream-connect 41.04% <ø> (-0.10%) ⬇️
plugins-test-and-upstream-graphql 40.22% <ø> (-0.10%) ⬇️
plugins-test-and-upstream-koa 40.68% <ø> (-0.10%) ⬇️
plugins-test-and-upstream-protobufjs 39.04% <ø> (-0.11%) ⬇️
plugins-test-and-upstream-rhea 44.15% <ø> (-0.13%) ⬇️
plugins-undici 39.39% <ø> (-0.10%) ⬇️
plugins-url 22.88% <ø> (ø)
plugins-valkey 38.08% <ø> (-0.14%) ⬇️
plugins-vm 22.88% <ø> (ø)
plugins-winston 34.26% <ø> (-0.10%) ⬇️
plugins-ws 40.74% <ø> (-0.10%) ⬇️
profiling-macos 40.05% <ø> (-0.10%) ⬇️
profiling-ubuntu 40.10% <ø> (-0.10%) ⬇️
profiling-windows 41.46% <ø> (-0.10%) ⬇️
serverless-azure-functions-client 22.88% <ø> (ø)
serverless-azure-functions-eventhubs 22.88% <ø> (ø)
serverless-azure-functions-servicebus 22.88% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@watson watson marked this pull request as ready for review February 4, 2026 11:39
@watson watson requested review from a team as code owners February 4, 2026 11:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

debugger Dynamic Instrumentation & Live Debugger semver-minor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant