Skip to content

[debugger] Add compliance tests for probe when condition errors#7018

Open
watson wants to merge 1 commit into
mainfrom
watson/debugger-condition-tests
Open

[debugger] Add compliance tests for probe when condition errors#7018
watson wants to merge 1 commit into
mainfrom
watson/debugger-condition-tests

Conversation

@watson
Copy link
Copy Markdown
Contributor

@watson watson commented May 26, 2026

Motivation

Tracers currently diverge in how they handle a probe whose when condition can't be evaluated - some silently drop the probe, some install it and then emit a snapshot with no eval error, some have no rate-limiting, etc.

This PR pins down the contract we want every tracer to follow and gives us a clear baseline to drive each tracer toward conformance.

There is no existing RFC for the eval-error rate-limit policy. This PR uses the system-test as the cross-tracer commitment: at most 1 eval-error snapshot per probe per 5 minutes. The rate matches dd-trace-py's implementation; the choice is deliberate (one snapshot is enough to alert the developer that a probe is misconfigured, anything more frequent is noise). Tracers that emit more frequently are tracked as bugs and will need to either adopt this rate or push back on the test.

Changes

Two new compliance test classes in tests/debugger/test_debugger_condition_errors.py:

  • Test_Debugger_Invalid_Condition_DSL (1 test)
    • test_invalid_condition_dsl_probe_rejected - a probe whose when DSL cannot be parsed must be rejected with a status=ERROR diagnostic and must not emit any snapshot.
  • Test_Debugger_Runtime_Condition_Error (3 tests)
    • test_runtime_condition_error_probe_installs - a structurally valid when must install successfully (the runtime failure happens later).
    • test_runtime_condition_error_emits_error_only_snapshot - when the condition raises at eval time, the tracer must emit a snapshot with evaluationErrors[] populated (mentioning the unbound symbol) and an empty captures field (no leaking of captured probe data).
    • test_runtime_condition_error_rate_limited - two probe hits >1s apart must produce at most 1 eval-error snapshot per probe (i.e. the 1/5min commitment). The >1s spacing ensures each hit clears any general per-second snapshot sampler, so anything dropping the second snapshot must be the eval-error-specific rate limiter doing its job.

Supporting changes:

  • New probe fixtures probe_invalid_condition_dsl.json / probe_runtime_condition_error.json.
  • One new entry in method_and_language_to_line_number (tests/debugger/utils.py) registering the line number for the Node.js LogProbe weblog method. The in-test conversion from method-probe to line-probe for Node.js is kept strictly local to this test file (with a docstring explaining why it's unsafe to generalize: method-probe -> line-probe is not a generally equivalent rewrite, and these tests only get away with it because they assert on diagnostics, not on captured data).
  • Two new SchemaBug(...) entries in tests/schemas/test_schemas.py covering a pre-existing schema-compliance gap in dd-trace-py that this PR's new tests surfaced for the first time (Python emits stack: null in eval-error snapshots; the schema requires an array). The bug existed but had never been triggered because no prior system-test exercised the eval-error code path. Tracked under the Python bug ticket.

Manifest updates (compliance markers, not characterization):

  • agent.yml - irrelevant for Go DI on datadog-agent < 7.77.1 (the when clause requires that agent version on Go). Scoped via weblog_declaration to the Go weblogs only so the constraint doesn't accidentally apply to non-Go runs against an old agent (addressed in review).
  • golang.yml, java.yml, nodejs.yml, php.yml, python.yml, ruby.yml, dotnet.yml - per-tracer bug or missing_feature markers for tests that don't yet conform. Bug tickets are placeholders to be replaced by each tracer team. Note: under the 1/5min rate-limit commitment above, all of java, nodejs, ruby, php, dotnet need a rate-limit bug marker (their current implementations are at 1/s or per-probe-configurable, not 1/5min).
  • Min-version gates use the released-version baselines that the language teams have established for their other DI tests.

Workflow

  1. Create your PR as draft
  2. Work on you PR until the CI passes
  3. Mark it as ready for review
    • Test logic is modified? -> Get a review from RFC owner.
    • Framework is modified, or non obvious usage of it -> get a review from R&P team

🚀 Once your PR is reviewed and the CI green, you can merge it!

🛟 #apm-shared-testing 🛟

Reviewer checklist

  • Anything but tests/ or manifests/ is modified ? I have the approval from R&P team
    • Note: the only utils/-adjacent change is a single new entry in method_and_language_to_line_number in tests/debugger/utils.py (purely test-helper code).
  • A docker base image is modified?
    • the relevant build-XXX-image label is present
  • A scenario is added, removed or renamed?

Copy link
Copy Markdown
Contributor Author

watson commented May 26, 2026

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

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 26, 2026

CODEOWNERS have been resolved as:

tests/debugger/test_debugger_condition_errors.py                        @DataDog/debugger @DataDog/system-tests-core
tests/debugger/utils/probes/probe_invalid_condition_dsl.json            @DataDog/debugger @DataDog/system-tests-core
tests/debugger/utils/probes/probe_runtime_condition_error.json          @DataDog/debugger @DataDog/system-tests-core
manifests/agent.yml                                                     @DataDog/system-tests-core
manifests/dotnet.yml                                                    @DataDog/apm-dotnet @DataDog/asm-dotnet
manifests/golang.yml                                                    @DataDog/dd-trace-go-guild
manifests/java.yml                                                      @DataDog/asm-java @DataDog/apm-java
manifests/nodejs.yml                                                    @DataDog/dd-trace-js
manifests/php.yml                                                       @DataDog/apm-php @DataDog/asm-php
manifests/python.yml                                                    @DataDog/apm-python @DataDog/asm-python
manifests/ruby.yml                                                      @DataDog/ruby-guild @DataDog/asm-ruby
tests/debugger/utils.py                                                 @DataDog/debugger @DataDog/system-tests-core
tests/schemas/test_schemas.py                                           @DataDog/system-tests-core

@datadog-prod-us1-3
Copy link
Copy Markdown
Contributor

datadog-prod-us1-3 Bot commented May 26, 2026

Pipelines  Tests

Fix all issues with BitsAI

⚠️ Warnings

🚦 2 Pipeline jobs failed

Testing the test | System Tests (python, dev) / End-to-end #1 / uwsgi-poc 1   View in Datadog   GitHub Actions

🔧 Fix in code (Fix with Cursor). 1 failed test. Assertion Error: no extra_services contains extraVegetables at tests/remote_config/test_remote_configuration.py:267

🧪 1 Test failed

tests.remote_config.test_remote_configuration.Test_RemoteConfigurationExtraServices.test_tracer_extra_services[uwsgi-poc] from system_tests_suite   View in Datadog (Fix with Cursor)
AssertionError: no extra_services contains extraVegetables
assert []

self = &lt;tests.remote_config.test_remote_configuration.Test_RemoteConfigurationExtraServices object at 0x7f980dbfbda0&gt;

    def test_tracer_extra_services(self):
        &#34;&#34;&#34;Test extra services field&#34;&#34;&#34;
    
        # filter extra services
        extra_services = []
...

Testing the test | all-jobs-are-green   View in Datadog   GitHub Actions

ℹ️ Info

No other issues found (see more)

❄️ No new flaky tests detected

Useful? React with 👍 / 👎

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: f7e3186 | Docs | Datadog PR Page | Give us feedback!

@watson watson force-pushed the watson/debugger-condition-tests branch from c2ee329 to 3717e1d Compare May 26, 2026 16:11
@watson watson marked this pull request as ready for review May 26, 2026 18:33
@watson watson requested review from a team as code owners May 26, 2026 18:33
@watson watson requested review from amarziali, daniel-romano-DD, jandro996, mabdinur and taegyunkim and removed request for a team May 26, 2026 18:33
Copy link
Copy Markdown

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

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: 3717e1dc86

ℹ️ 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 manifests/agent.yml Outdated
Comment thread tests/debugger/test_debugger_condition_errors.py
@watson watson force-pushed the watson/debugger-condition-tests branch from 3717e1d to 81ac26c Compare May 26, 2026 19:24
Add system tests that pin down the contract for two distinct failure paths
when a dynamic-instrumentation probe's `when` condition can't be evaluated:

* Invalid DSL at install time: the probe must be rejected and the tracer
  must emit a `status=ERROR` diagnostic so the developer knows the probe
  was dropped. No snapshot may be produced.
* Structurally valid `when` that raises at runtime: the probe must install
  successfully and, when the condition raises, the tracer must emit a
  snapshot with `evaluationErrors[]` populated (mentioning the failing
  symbol) and NO captured data. These eval-error snapshots must also be
  rate-limited so a hot probe doesn't spam the user.

The tests assert the ideal behavior; existing per-tracer deviations are
recorded via manifest `bug` / `missing_feature` / `irrelevant` markers.

Co-authored-by: Cursor <cursoragent@cursor.com>
@watson watson force-pushed the watson/debugger-condition-tests branch from 81ac26c to f7e3186 Compare May 26, 2026 19:34
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