← Back to Pull requests

Fix tracestats bucket-boundary flakes (TS003/4/9) #8519

Open
unknown opened this pull request with 413 lines diff across 5 files
View on GitHub
unknown unknown commented on Nov 16, 2026 09:15 UTC
Author

<!-- dd-meta {"pullId":"8ffc9de6-9caf-44d4-818d-71a5df5180c9","source":"chat","resourceId":"40b5946d-f1ed-43a7-93a9-08eccbaf8400","workflowId":"10fa511e-b9fa-410c-bc90-b25b217c0755","codeChangeId":"10fa511e-b9fa-410c-bc90-b25b217c0755","sourceType":"code_channel"} -->

Motivation

This came out of the test failure triage for the Language Platform Green CI SLI report (Nov 13–15). The only LP failure was Test_Library_Tracestats::test_metrics_computed_after_span_finsh_TS009 on nodejs 6.24.0 (Nightly, 2026-11-13). It failed with There should be one bucket containing the stats / assert 2 == 1.

Client-side stats are grouped into 10s time buckets. When the spans of a test finish on both sides of a bucket boundary, the library reports them in two buckets, and the test fails. The cause is the test, not the tracer. The same failure hit TS003 (nodejs, golang) and TS004 (golang): at least 4 failures in the last 90 days. On nodejs, TS003 was marked flaky (APMLP-2085) for this reason, so it has not run since Oct 20.

Changes

  • tests/parametric/test_library_tracestats.py: new _merged_v06_stats helper. It merges the decoded stats entries of every request and every time bucket by aggregation key, and sums their counters (Hits, TopLevelHits, Duration, Errors). Within a single bucket it still requires one entry per key, so a library that fails to aggregate is still caught.

  • TS003, TS004 and TS009 use this helper instead of asserting a single bucket or reading only bucket [0]. The checks on counters and dimensions are unchanged. TS009 still fails if a span's aggregation key changes after finish.

  • manifests/nodejs.yml: removed the flaky (APMLP-2085) entry on TS003 (>=6.21.0), because this fixes its cause. APMLP-2085 can be closed once this is merged.
  • Testing:

  • mypy (strict), ruff format and ruff check, lint-imports, yamlfmt -lint manifests/, yamllint, and utils/manifest/format.py / validate.py all pass.

  • I checked the merge logic with synthetic payloads: a split across buckets, a key change after finish, a duplicate key within a bucket, and input not mutated.

  • I did not run the PARAMETRIC scenario locally because there is no Docker in the sandbox. This PR's CI will run it.
  • Follow-ups, not in this PR:

  • TS005 and TS006 have the same single-bucket assumption, but have not failed in the last 90 days.

  • TS009 still asserts exactly one stats request.
  • Workflow

    1. ⚠️ Create your PR as draft ⚠️
    2. Work on you PR until the CI passes
    3. Mark it as ready for review
    Tests, manifest, weblog are modified -> you'll need a review from system-tests-reviewers: ask to one of youre co-worker familiar with the tested feature.
    Framework is modified, or non obvious usage of it -> get a review from system-tests-core (slack)

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

    🛟 #apm-shared-testing 🛟

    🤖 Generated with <span>Claude Code</span> (<span>https://claude.com/claude-code</span>)

    ---

    PR by Bits - View session in Datadog • Open in Slack

    Comment @datadog to request changes

    Diff: 413 lines (+309 / -104) across 5 files Reviewer: ichinaski Review duration: 1768m
    All Vouch review confidence checks passed
    Residual risk 0.24 = Change Risk (0.45) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.45 · 413 lines diff across 5 files
    0.45
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.361
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #8519"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 44.9% (MEDIUM) · Higher = larger blast radius
    44.9%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 46.7% · Lower = rushed or shallow review
    46.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 23.9% · Safe to merge
    23.9%