Skip to content

fix(parametric): wait for client-side stats before asserting p0 dropping#7326

Merged
bm1549 merged 1 commit into
mainfrom
brian.marks/parametric-wait-css-stats
Jul 17, 2026
Merged

fix(parametric): wait for client-side stats before asserting p0 dropping#7326
bm1549 merged 1 commit into
mainfrom
brian.marks/parametric-wait-css-stats

Conversation

@bm1549

@bm1549 bm1549 commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Motivation

test_*_when_dropping_policy_is_active016/017/018 in tests/parametric/test_span_sampling.py assert client-side p0 dropping right after tracer startup. p0 dropping only turns on once the tracer's async /info fetch confirms the agent supports it, so a span flushed before that handshake completes is forwarded to the agent undropped. That is a startup race, not a tracer bug: dd-trace-java and dd-trace-dotnet also send p0 traces until /info lands, and the agent recomputes stats and drops them. It surfaced as a flaky [parametric-rust] failure because the test is enabled for few tracers and rust's /info fetch can lose the race. Approach confirmed with Vianney Ruhlmann in #apm-client-side-stats.

Changes

Add _wait_for_client_side_stats_active: before the assertions, warm up until the test agent receives a /v0.6/stats payload (which proves stats and p0 dropping are active), then clear the warm-up traffic. Reuses the existing TestAgentAPI.wait_for_num_v06_stats primitive and mirrors the wait_for_client_side_stats_payload approach the stats tests already use. Applied to all three dropping-policy tests (016/017/018).

Only tests/ is modified.

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
  • A docker base image is modified?
    • the relevant build-XXX-image label is present
  • A scenario is added, removed or renamed?

`test_*_when_dropping_policy_is_active016/017/018` asserted client-side p0 dropping
immediately after tracer startup. p0 dropping only activates once the tracer's async
`/info` fetch confirms the agent supports it, so a span flushed before that handshake
is forwarded to the agent undropped. This is a startup race, not a tracer bug (dd-trace
-java and dd-trace-dotnet also send p0 traces until `/info` lands; the agent recomputes
stats and drops them). It surfaced as a flaky `[parametric-rust]` failure because the
test is enabled for few tracers and rust's `/info` fetch can lose the race.

Add `_wait_for_client_side_stats_active`: warm up until the agent receives a `/v0.6/stats`
payload (proving stats / p0 dropping are active), then clear, before running the
assertions. Reuses the existing `TestAgentAPI.wait_for_num_v06_stats` polling primitive
and mirrors the `wait_for_client_side_stats_payload` approach used by the stats tests.
Applied to all three dropping-policy tests.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@bm1549 bm1549 added the ai-generated The pull request includes a significant amount of AI-generated code label Jul 16, 2026
@github-actions

Copy link
Copy Markdown
Contributor

CODEOWNERS have been resolved as:

tests/parametric/test_span_sampling.py                                  @DataDog/system-tests-core @DataDog/apm-sdk-capabilities

@datadog-datadog-us1-prod

datadog-datadog-us1-prod Bot commented Jul 16, 2026

Copy link
Copy Markdown

Tests

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

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

@bm1549
bm1549 marked this pull request as ready for review July 16, 2026 19:35
@bm1549
bm1549 requested review from a team as code owners July 16, 2026 19:35
@bm1549
bm1549 requested review from mhlidd and removed request for a team July 16, 2026 19:35
@bm1549
bm1549 merged commit 8faf8fe into main Jul 17, 2026
841 of 843 checks passed
@bm1549
bm1549 deleted the brian.marks/parametric-wait-css-stats branch July 17, 2026 12:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-generated The pull request includes a significant amount of AI-generated code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants