fix(traces): keep backend as safety net for trace stats#1171
fix(traces): keep backend as safety net for trace stats#1171duncanista wants to merge 1 commit intomainfrom
Conversation
cad01da to
ba83898
Compare
There was a problem hiding this comment.
Pull request overview
This PR fixes a critical bug in trace stats generation where stats could disappear after upgrading to v95. The issue was introduced in PR #1118, where the extension would set _dd.compute_stats: "0" when a tracer claimed to have computed stats via the Datadog-Client-Computed-Stats header. If those tracer stats didn't reach the backend (due to tracer bugs or misconfiguration), stats would vanish entirely with no fallback.
The fix changes _dd.compute_stats to be determined solely by compute_trace_stats_on_extension, ignoring client_computed_stats. This keeps the backend as a safety net that can always compute stats if needed, while client_computed_stats continues to prevent duplicate stats from the extension (when compute_trace_stats_on_extension=true).
Changes:
- Updated
_dd.compute_statsdetermination logic intrace_processor.rsto depend only oncompute_trace_stats_on_extension - Updated all four test cases and their expectations to match the new behavior
- Bumped extension version from "94-next" to "95-next"
Reviewed changes
Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| bottlecap/src/traces/trace_processor.rs | Updated compute_stats logic and all test expectations |
| bottlecap/src/tags/lambda/tags.rs | Bumped extension version to 95-next |
ba83898 to
33f05be
Compare
…laims client-computed-stats The Datadog-Client-Computed-Stats header should only suppress extension-side stats generation, not backend stats. When the extension is not computing stats itself, always set _dd.compute_stats:1 so the backend remains a fallback.
33f05be to
99bfcfe
Compare
|
Drafting due to #1172 |
|
Also failing internal testing. |
Summary
Fixes trace stats "disappearing" after upgrading to v95.
PR #1118 (
55659d9) introduced logic to respect theDatadog-Client-Computed-Statsheader from tracers. When a tracer sends this header as truthy, the extension would:_dd.compute_stats: 0on the trace payload, telling the backend to also skip stats (problematic)This created a scenario where all three stats sources could be disabled simultaneously:
DD_COMPUTE_TRACE_STATS_ON_EXTENSIONDatadog-Client-Computed-Stats_dd.compute_statsIf the tracer claims it computed stats but those stats don't actually reach the backend (tracer bug, misconfiguration, or the header is sent without stats being computed), stats vanish entirely. In v94, the backend always acted as a safety net (
_dd.compute_stats: 1).Fix
_dd.compute_statsis now determined solely bycompute_trace_stats_on_extension, ignoringclient_computed_stats:DD_COMPUTE_TRACE_STATS_ON_EXTENSIONDatadog-Client-Computed-Stats_dd.compute_statsThe
client_computed_statsheader still correctly suppresses extension-side stats generation (the&& !client_computed_statsguard onstats_generator.send()), preserving the dedup behavior from #1118 whenDD_COMPUTE_TRACE_STATS_ON_EXTENSION=true.Worst case with this fix is double-counted stats (tracer + backend) — far better than zero stats.
Test plan
check_compute_stats_behaviorcovers all 4 combinations)