Repository navigation
Conversation
Every snapshot probe made its own sampling decision, so the snapshots of probes hit in the same request arrived incomplete: the snapshot of one probe could be emitted while the snapshot of a probe that explains it was dropped, with no signal that anything was missing. Make the sampling decision once per trace instead. The first snapshot-producing probe hit in a trace decides for all of them, subject to its per-probe rate limit and the global snapshot rate limit, so a trace emits the snapshots of all of its probes or none of them. In a sampled trace each probe emits once, which also keeps a probe in a loop from emitting a snapshot per iteration. Those snapshots bypass the rate limits, so the set stays complete, but still count toward them, so later traces are less likely to be sampled and the overall volume stays close to the limits. The decision is made in the breakpoint condition on the instrumented thread, before it pauses, so a dropped trace costs no pause. It is keyed weakly on the trace object shared by the spans of a trace in this process, so it is released together with the trace. Probes hit without an active span, and probes hit in a trace whose spans have all finished, e.g. in a callback bound to a request that has since ended, are sampled independently as before. Probes that don't produce snapshots are not affected. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Overall package sizeSelf size: 9.45 MB Dependency sizes| name | version | self size | total size | |------|---------|-----------|------------| | import-in-the-middle | 3.5.1 | 127.66 kB | 531.94 kB | | opentracing | 0.14.7 | 194.81 kB | 194.81 kB | | dc-polyfill | 0.1.11 | 25.74 kB | 25.74 kB |🤖 This report was automatically generated by heaviest-objects-in-the-universe |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #10677 +/- ##
========================================
Coverage 98.87% 98.87%
========================================
Files 1058 1058
Lines 171887 171989 +102
Branches 74 74
========================================
+ Hits 169949 170051 +102
Misses 1938 1938
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
✅ All CI checks and tests passed. Datadog automation helped this PR pass. 🎉 All green!🧪 All tests passed 🔄 Datadog retried 1 test - 1 passed on retry 🎯 Code Coverage (details) 🔗 Commit SHA: 9ce8658 | Docs | View more details | Give us feedback! |
BenchmarksBenchmark execution time: 2026-10-07 19:01:39 Comparing candidate commit 9ce8658 in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 2386 metrics, 17 unstable metrics.
|
Add the `/debugger/correlation` and `/debugger/correlation/loop/:count` endpoints to the Node.js Express, TypeScript Express and Fastify weblogs, mirroring the Go endpoints: the probed functions return 400ms apart, and the loop sleeps for a second per iteration. Node.js doesn't support method probes, so the correlation tests point each probe at the line its method returns on for Node.js instead, using new Node.js entries in the line map. The new routes move the capture timeout line from 157 to 159, and the budgets line from 163 to 165. Enable `Test_Debugger_Coordinated_Sampling` and `test_per_span_budget` from the dd-trace-js release that ships coordinated snapshot sampling (DataDog/dd-trace-js#10677). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Add the `/debugger/correlation` and `/debugger/correlation/loop/:count` endpoints to the Node.js Express, TypeScript Express and Fastify weblogs, mirroring the Go endpoints: the probed functions return 400ms apart, and the loop sleeps for a second per iteration. Node.js doesn't support method probes, so the correlation tests point each probe at the line its method returns on for Node.js instead, using new Node.js entries in the line map. The new routes move the capture timeout line from 157 to 159, and the budgets line from 163 to 165. Enable `Test_Debugger_Coordinated_Sampling` and `test_per_span_budget` from the dd-trace-js release that ships coordinated snapshot sampling (DataDog/dd-trace-js#10677). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Add the `/debugger/correlation` and `/debugger/correlation/loop/:count` endpoints to the Node.js Express, TypeScript Express and Fastify weblogs, mirroring the Go endpoints: the probed functions return 400ms apart, and the loop sleeps for a second per iteration. Node.js doesn't support method probes, so the correlation tests point each probe at the line its method returns on for Node.js instead, using new Node.js entries in the line map. The new routes move the capture timeout line from 157 to 159, and the budgets line from 163 to 165. Enable `Test_Debugger_Coordinated_Sampling` and `test_per_span_budget` from the dd-trace-js release that ships coordinated snapshot sampling (DataDog/dd-trace-js#10677). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
What does this PR do?
Makes the sampling decision for snapshot probes once per trace instead of once per probe hit, so a trace emits the snapshots of all of its probes or none of them.
snapshotsPerSecondand the global 25/s snapshot limit.The decision is made by the main-thread sampler inside the breakpoint condition, before the thread pauses, so a dropped trace costs no pause. It's keyed in a
WeakMaponspan.context()._trace, the object shared by all spans of a trace in this process, so it's released together with the trace.Motivation
DEBUG-5831, from the RFC: Improving Correlation for Live Debugger Snapshots. With every probe sampling on its own, related snapshots from one request arrive incomplete, with no signal that anything is missing, which misleads both users and AI agents reading a session.
The decision semantics match Java (DataDog/dd-trace-java#12452), with two Node-specific differences:
Additional Notes
snapshotsPerSecondwould have skipped it._traceon Node 18, 20, 22 (with and without--experimental-async-context-frame), 24 and 26. Scenarios covered: no span, synchronous, child span,activate(null), afterawait,setTimeout, a stale callback after the trace finished, and 20 concurrent HTTP requests interleaving across awaits.Test_Debugger_Coordinated_Samplingand new weblog endpoints. That will be a follow-up system-tests PR once test(debugger): add snapshot-correlation gate and Go weblog endpoints system-tests#7425 has landed.Performance (Node 24.14.1, macOS arm64):
The sampler call itself (
makeSampleDecisionfor a snapshot probe; 2M hits per run, median of 15 runs):A whole rejected breakpoint hit, from V8's debug break through condition evaluation, costs about 100–300 µs, so the extra ~10 ns can't be measured end to end. Inside an active span, master vs this PR measured −0.4% (20k hits per run, median of 11 runs). The same setup with master against itself measured −6.8%, which gives the noise floor.
Existing sirun debugger variants, before vs after (these run without an active span):
For the minimal and without-snapshot variants, the local runs relaxed
STARTUP_GUARD_MAX_SHARE: run outside the CI harness, sirun counts startup time toward that guard.Validation:
./node_modules/.bin/mocha packages/dd-trace/test/debugger/probe_sampler.spec.js: 57 passing, 15 of them new.npm run test:debugger: 836 passing../node_modules/.bin/mocha --timeout 60000 "integration-tests/debugger/*.spec.js": 130 passing. The newcoordinated-sampling.spec.jsalso passed 5 runs in a row.tsc -p tsconfig.debugger.jsonreports no new errors.🤖 Generated with Claude Code