Skip to content

feat(debugger): report guardrail telemetry metrics - #10152

Open
watson wants to merge 12 commits into
masterfrom
watson/DEBUG-6081/guardrail-metrics
Open

feat(debugger): report guardrail telemetry metrics#10152
watson wants to merge 12 commits into
masterfrom
watson/DEBUG-6081/guardrail-metrics

Conversation

@watson

@watson watson commented Sep 4, 2026

Copy link
Copy Markdown
Collaborator

What does this PR do?

Adds three debugger guardrail metrics in the live_debugger telemetry namespace:

  • events.skipped{reason,event_type} - probe hits stopped before an event was created (rateLimitProbe, rateLimitGlobal)
  • events.dropped{reason,event_type} - complete events discarded before transport (reason codes only; the drop paths land in the next PR)
  • capture.incomplete{reason,event_type} - captures where a limit was enforced (runtimeError, timeout, depth, fieldCount, collectionSize, stringLength, payloadTooLarge, other), counted once per event per reason

Also reports dynamic_instrumentation.enabled in the telemetry products payload.

Motivation

Rate limits are decided by the probe sampler inside the V8 breakpoint condition on the main thread, capture limits are enforced in the debugger worker. To keep both hot paths cheap the counters live in a SharedArrayBuffer incremented with atomics, and the main thread drains them into telemetry metrics every 10 seconds and when the debugger stops.

Additional Notes

Namespace and tag set follow the shipped .NET and Python implementations. probe_id is intentionally not a tag.

@github-actions github-actions Bot added semver-minor debugger Dynamic Instrumentation & Live Debugger labels Sep 4, 2026
@datadog-datadog-prod-us1-2

datadog-datadog-prod-us1-2 Bot commented Sep 4, 2026

Copy link
Copy Markdown

Pipelines  Tests

⚠️ Warnings

Your PR has failed checks. Please review the issues below and take necessary action before merging.

🚦 3 Pipeline jobs failed

All Green | all-green

View more details · View in GitHub Actions

Workflow run 34112494054 (System Tests) failed after retry, failing immediately.

System Tests | main / parametric / parametric (1)

View more details · View in GitHub Actions

Failed to fetch package 'libperl5.32' during apt-get update. Error 404: Not Found.

System Tests | main / parametric / parametric (3)

View more details · View in GitHub Actions

Failed to build framework test server image due to 404 Not Found error while fetching packages from Debian repository.

ℹ️ Info

No other issues found (see more)

🧪 All tests passed
❄️ No new flaky tests detected

🎯 Code Coverage (details)
Patch Coverage: 100.00%
Overall Coverage: 98.03% (-0.20%)

Useful? React with 👍 / 👎

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 12d404b | Docs | View more details | Give us feedback!

@dd-octo-sts

dd-octo-sts Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Overall package size

Self size: 8.84 MB
Deduped: 9.51 MB
No deduping: 9.51 MB

Dependency sizes | name | version | self size | total size | |------|---------|-----------|------------| | import-in-the-middle | 3.4.0 | 127.33 kB | 447.04 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

codecov Bot commented Sep 4, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.65%. Comparing base (ca391e1) to head (12d404b).

Additional details and impacted files
@@           Coverage Diff            @@
##           master   #10152    +/-   ##
========================================
  Coverage   98.65%   98.65%            
========================================
  Files        1005     1007     +2     
  Lines      157435   157793   +358     
  Branches       74       74            
========================================
+ Hits       155312   155670   +358     
  Misses       2123     2123            
Flag Coverage Δ
ai-guard 65.00% <100.00%> (-0.02%) ⬇️
apm-capabilities 63.11% <70.92%> (+0.01%) ⬆️
apm-integrations 81.41% <100.00%> (-0.02%) ⬇️
appsec 58.71% <100.00%> (-0.01%) ⬇️
debugger 70.09% <100.00%> (+0.26%) ⬆️
instrumentation 53.72% <100.00%> (-0.01%) ⬇️
llmobs 79.00% <100.00%> (-0.02%) ⬇️
master-coverage 98.65% <100.00%> (?)
openfeature 66.38% <100.00%> (-0.03%) ⬇️
platform 69.31% <100.00%> (-0.01%) ⬇️
profiling 66.75% <100.00%> (-0.02%) ⬇️
serverless 65.71% <100.00%> (-0.02%) ⬇️
test-optimization 82.67% <68.73%> (-0.01%) ⬇️

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

☔ View full report in Codecov by Harness.
📢 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.

@pr-commenter

pr-commenter Bot commented Sep 4, 2026

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2026-09-07 10:53:08

Comparing candidate commit 12d404b in PR branch watson/DEBUG-6081/guardrail-metrics with baseline commit ca391e1 in branch master.

📊 Benchmarking dashboard

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

Explanation

This is an A/B test comparing a candidate commit's performance against that of a baseline commit. Performance changes are noted in the tables below as:

  • 🟩 = significantly better candidate vs. baseline
  • 🟥 = significantly worse candidate vs. baseline

We compute a confidence interval (CI) over the relative difference of means between metrics from the candidate and baseline commits, considering the baseline as the reference.

If the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD), the change is considered significant.

Feel free to reach out to #apm-benchmarking-platform on Slack if you have any questions.

More details about the CI and significant changes

You can imagine this CI as a range of values that is likely to contain the true difference of means between the candidate and baseline commits.

CIs of the difference of means are often centered around 0%, because often changes are not that big:

---------------------------------(------|---^--------)-------------------------------->
                              -0.6%    0%  0.3%     +1.2%
                                 |          |        |
         lower bound of the CI --'          |        |
sample mean (center of the CI) -------------'        |
         upper bound of the CI ----------------------'

As described above, a change is considered significant if the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD).

For instance, for an execution time metric, this confidence interval indicates a significantly worse performance:

----------------------------------------|---------|---(---------^---------)---------->
                                       0%        1%  1.3%      2.2%      3.1%
                                                  |   |         |         |
       significant impact threshold --------------'   |         |         |
                      lower bound of CI --------------'         |         |
       sample mean (center of the CI) --------------------------'         |
                      upper bound of CI ----------------------------------'

Unstable benchmarks

These benchmarks have a confidence interval too wide to call a change; treat them as noise rather than signal.

scenario:appsec-iast-no-vulnerability-iast-enabled-default-config-20

  • unstable max_rss_usage [-16.637MB; +31.576MB] or [-7.260%; +13.779%]

scenario:encoders-0.4-immediate-flush-20

  • unstable max_rss_usage [-5.780MB; +10.718MB] or [-7.307%; +13.550%]

scenario:llmobs-encode-unicode-mixed-20

  • unstable max_rss_usage [-9406.143KB; +9129.343KB] or [-12.303%; +11.941%]

scenario:plugin-graphql-long-with-depth-and-collapse-off-24

  • unstable cpu_user_time [-586.033ms; +543.480ms] or [-5.339%; +4.952%]
  • unstable execution_time [-584.198ms; +545.264ms] or [-5.249%; +4.900%]

scenario:plugin-pg-service-26

  • unstable execution_time [-90.811ms; +122.574ms] or [-5.553%; +7.495%]

@watson
watson marked this pull request as ready for review September 4, 2026 08:15
@watson
watson requested review from a team as code owners September 4, 2026 08:15
@watson
watson requested a review from BridgeAR September 4, 2026 08:15
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 4, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-06T09:09:13.504891Z 727ac7c New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ce71ea9034

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/dd-trace/src/debugger/index.js
Comment thread packages/dd-trace/src/debugger/index.js Outdated
Comment thread packages/dd-trace/src/debugger/probe_sampler.js
Comment thread packages/dd-trace/src/debugger/devtools_client/index.js
Comment thread packages/dd-trace/src/debugger/devtools_client/index.js Outdated
@watson
watson force-pushed the watson/DEBUG-6081/guardrail-metrics branch from ce71ea9 to c178928 Compare September 4, 2026 09:54

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c17892892a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/dd-trace/src/debugger/devtools_client/send.js
Comment thread packages/dd-trace/src/debugger/devtools_client/snapshot/index.js
Comment thread packages/dd-trace/src/debugger/devtools_client/snapshot/processor.js Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9431a7bf79

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/dd-trace/src/debugger/devtools_client/snapshot/index.js Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4e7b0a8fde

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/dd-trace/src/debugger/devtools_client/snapshot/index.js Outdated
Add the three Dynamic Instrumentation guardrail metrics required by the
"Debugger Observability for GA" specification, in the `live_debugger`
telemetry namespace shared with the other tracers:

- `events.skipped{reason,event_type}` for probe hits stopped before an
  event was created (`rateLimitProbe`, `rateLimitGlobal`)
- `events.dropped{reason,event_type}` for complete events discarded
  before transport (reason codes only; the drop paths land separately)
- `capture.incomplete{reason,event_type}` for captures where a limit was
  enforced (`runtimeError`, `timeout`, `depth`, `fieldCount`,
  `collectionSize`, `stringLength`, `payloadTooLarge`, `other`), counted
  once per event per reason

Rate limits are decided by the probe sampler inside the V8 breakpoint
condition on the main thread, while capture limits are enforced in the
debugger worker. To keep both hot paths cheap, counters live in a
SharedArrayBuffer incremented with atomics, and the main thread drains
them into telemetry metrics every 10 seconds and when the debugger is
stopped.

Also report `dynamic_instrumentation.enabled` in the telemetry products
payload, as required by the same specification.
The flush interval timer is unref'ed and the debugger worker does not
keep the process alive, so when an application exits on its own
everything counted since the last 10 second tick was lost: `stop()` is
never called in that case, and telemetry sends its final metrics from
its `beforeExit` handler before the timer fires again. For a
short-lived process that could be every counter.

Telemetry publishes the `datadog:telemetry:app-closing` channel right
before that final send, precisely so listeners can update their metrics
first. Drain the counters on that channel while the debugger is running.
`Worker#terminate()` only interrupts the worker asynchronously, so a
counter the worker increments between the final drain and its actual
termination is lost. Those counters can only describe events that are
still in the worker's upload buffer, which are discarded together with
the worker, so a drain ordered after the worker's exit would not report
anything an observer could act on. Spell that out next to the drain.
The paused handler treated every fatal capture error as a runtime error
when tagging `capture.incomplete`. The collector however also raises a
fatal error on purpose when an object exceeds the large object safety
threshold, to disable future captures for the probe. Nothing threw in
that case; the object was trimmed to the field count limit, which the
processor already reports. The event was counted as both `fieldCount`
and a bogus `runtimeError`.

Record the runtime error reason where the errors originate instead:
when a scope cannot be read, when a capture expression throws and when
it cannot be evaluated at all. The safety threshold keeps disabling the
capture but is reported as the limit it is.
Messages longer than 8 KiB are cut down before the event is queued for
upload, which is a limit enforced by the tracer just like pruning an
oversized snapshot is, but unlike the pruning it was not reported. Record
it as the string length limit so `capture.incomplete{stringLength}`
covers log events whose message was trimmed.
A scope with more variables than the field count limit is trimmed by
the collector like any other object, which marks the returned array
with the field count symbol. The scope itself is not part of the
snapshot though: its variables are spread into the local state and the
marker was lost with the array, so the extra variables were dropped
without `capture.incomplete{fieldCount}` being reported.

Record the limit when the collector returns a trimmed scope.
A property was processed first and redacted afterwards, so any limit
enforced while processing its value (a string trimmed to the maximum
length, an object cut off at the reference depth, ...) was recorded as
an incomplete capture reason, although the whole value is replaced by
the redaction marker and none of those limits show in the snapshot.

Decide on the redaction first, like the map entry path already does,
and process a redacted value without recording the limits it hits.
Two of the specs replace `process.hrtime.bigint` with a stub that
advances the clock by 50 ms on every call, and only the fake timers were
restored afterwards. Any spec collecting a snapshot later in the same
process then ran into the capture deadline immediately, which now bites
the pause handler spec covering the large object safety threshold.
Reaching the capture deadline was recorded as an incomplete capture
unconditionally, on top of the timeout markers the collector puts on
the nodes it skips. The markers are what the processor reports, and they
are ignored for a value that ends up redacted, so when the deadline was
reached inside the only value of the last scope and that value was
redacted, the metric still reported a timeout the snapshot does not show.

The unconditional bit was there for the scopes remaining after the
deadline, which are dropped without any marker. Only record it when such
scopes exist.
Same as for the local state: reaching the deadline while evaluating
capture expressions was recorded unconditionally, although the nodes cut
within the expression being collected carry the collector's timeout
marker and are recorded when processed, unless they end up redacted.
Only the expressions skipped after the deadline are returned as bare
stubs without any marker, so only record the timeout for those.
…line

Compare against the last collectable scope instead of scanning the rest
of the chain with an index based loop and a second helper. Also let the
snapshot test util trigger a breakpoint with any function, so the
incomplete capture spec no longer needs its own copy of the helper.
@watson
watson force-pushed the watson/DEBUG-6081/guardrail-metrics branch from eec56f3 to 727ac7c Compare September 6, 2026 09:05
Co-authored-by: Cursor <cursoragent@cursor.com>
@watson
watson requested a review from a team as a code owner September 7, 2026 10:38
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.

2 participants