Skip to content

fix(debugging): report metric probe value evaluation errors - #21176

Open
timsee wants to merge 9 commits into
DataDog:mainfrom
timsee:timsee/di-metric-value-eval-errors
Open

timsee wants to merge 9 commits into
DataDog:mainfrom
timsee:timsee/di-metric-value-eval-errors

Conversation

@timsee

@timsee timsee commented Oct 22, 2026 •

Copy link
Copy Markdown

Found a bug while building on top of metric probes for dynamic instrumentation. The bug came from an agent attempting dictionary lookups with dot notation (cfg.max_ms) which applied without error, reported ACTIVE but never emitted results (silly agent, dot notation doesnt work for dictionaries but i know expression language is tough and does nudge you to use it). Doing dictionary lookups with bracket notation (cfg["max_ms"]) worked fine in the same location. Part of the confusion here is what ACTIVE means in python, it reports ACTIVE as soon as it can validate the line is fine and can be installed, but it does not test the expression at this time. the expression tests after the first call, which is when it can call set_error. because we were swallowing that error, we never flipped ACTIVE to ERROR. Update: we do not report invalid conditions that can never fire as ERROR in a regular case, we only report their errored state in the snapshot but we keep the probes as ACTIVE. This PR matches that logic, and allows us to report this error at all.

The core bug was that instead of reporting this was an error, we swallowed the exception:

  1. probe.value(scope) raises inside sample().
  2. nothing in sample(), exit() or do_exit() caught it, so all their remaining lines are skipped.
  3. the catch-all in _close_signal caught it which logs telemetry and continues, and calls continue which skips the collector.push(signal) making it a silent failure.

The proposed fix:

  1. trys and catches the probe.value(scope)
  2. records an EvaluationError, sets a COND_ERROR or SKIP_COND_ERROR and returns normally.
  3. now that we return normally, we continue normally, and get back up to _close_signal() without an exception, so we can call collector.push(signal), which is now set to COND_ERROR or SKIP_COND_ERROR.

@timsee
timsee marked this pull request as ready for review October 22, 2026 19:33
@timsee
timsee requested review from a team as code owners October 22, 2026 19:33
@timsee
timsee requested review from ncybul and removed request for a team October 22, 2026 19:33
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 22, 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-11-03T15:14:03.774148Z 5adad70 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: ae85e485f1

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@datadog-official datadog-official Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Bits Code Review: PASS

More details

Metric-value evaluation failures preserve their error state through signal completion, allowing the collector to report them instead of silently dropping the signal. Runtime behavior remains unverified.

Was this helpful? React 👍 or 👎

Open Bits AI session

🤖 Bits Code Review · Commit ae85e48

@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: 4f185074a0

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@P403n1x87 P403n1x87 left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for tracking this down, the diagnosis is spot on: the exception escapes sample() and the catch-all in _close_signals / _dd_debugger_hook drops the signal before it reaches the collector. The overall shape of the fix looks right to me. A few things before this goes in:

PR description overclaims the effect on probe status. Pushing a COND_ERROR signal does not flip the probe from installed/active to ERROR. In collector.py a COND_ERROR signal only bumps the guardrails.evaluation.errors metric and enqueues a log carrying evaluationErrors; probe status only goes to ERROR via ProbeRegistry.set_error, which is only called for install-time failures. So after this change the user gets an evaluation-error log (same as for a failing condition), and the probe simply never becomes EMITTING. That's a good outcome, but could you update the description to match?

Guardrail metric tagging (not in the diff). Since value errors reuse COND_ERROR, the collector will tag them error_kind: "condition". Either a distinct state/tag, or at least a comment noting the reuse is deliberate, would keep the guardrail dashboards honest. Same for sharing condition_error_limiter with genuine condition errors: probably fine, but worth stating as a choice.

Nice touches: naming only the type for non-numeric values so nothing sensitive lands in the message, and covering OverflowError.

Comment thread tests/debugging/test_debugger.py Resolved
Comment thread tests/debugging/test_debugger.py Resolved

@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: 5d8f62e301

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread ddtrace/debugging/_signal/model.py Resolved

@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: c7d582e6f2

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@P403n1x87 P403n1x87 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thank you! 🙇

@datadog-official

datadog-official Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Pipelines  Tests

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

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

@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: 5adad70bdd

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread ddtrace/debugging/_probe/model.py Resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants