[SVLS-8734] fix(traces): restore _dd.compute_stats to span meta to fix missing trace stats#1172
Closed
[SVLS-8734] fix(traces): restore _dd.compute_stats to span meta to fix missing trace stats#1172
Conversation
…ace.aws.lambda.hits PR #1118 moved `_dd.compute_stats` from each span's `meta` (applied via `get_tags_map()` / `ChunkProcessor`) to the payload-level `tracer_payload.tags` only. The Datadog APM backend reads this signal from the root span's `meta` field, not from the payload-level tags, so it stopped computing stats and `trace.aws.lambda.hits` disappeared from the trace explorer. Fix: propagate `_dd.compute_stats` to every span's `meta` in the same loop that writes it to `tracer_payload.tags`, restoring the pre-#1118 behavior while keeping the payload-level tag as well. Also add debug logging to `handle_traces` to surface the header tags on every incoming trace request, which aids diagnosing similar issues. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…n span meta Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…om payload tags - Add `compute_stats_value` field to `ChunkProcessor` so the tag is set on each span's meta alongside the other function tags, instead of in a separate post-processing loop. - Remove `_dd.compute_stats` from `tracer_payload.tags`: it was never set there before PR #1118 and is not needed — stats work via the span meta path alone. - Compute and log the value once at the top of `process_traces`, before constructing `ChunkProcessor`. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ad of pre-computed value Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…bda_span to check span meta _dd.compute_stats is now set on span meta instead of payload tags. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes the missing trace stats issue by restoring _dd.compute_stats to span metadata. PR #1118 had moved this tag to payload-level tags, but the backend expects it on individual spans to properly calculate trace statistics.
Changes:
- Move
_dd.compute_statsback into individual span'smetafield (previously moved to payload tags in PR #1118) - Add
client_computed_stats: boolfield toChunkProcessorto track whether client has already computed stats - Remove
_dd.compute_statsfromtracer_payload.tagswhere it was incorrectly placed - Update tests to verify the tag is set on spans, not on payload level
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| bottlecap/src/traces/trace_processor.rs | Moves _dd.compute_stats logic to ChunkProcessor::process() to set it on each span's meta based on both compute_trace_stats_on_extension and client_computed_stats config, removes the incorrect payload-level tag setting, and updates all related tests |
| bottlecap/src/lifecycle/invocation/processor.rs | Updates test assertions to verify _dd.compute_stats is in span metadata rather than payload tags |
3 tasks
duncanista
approved these changes
Apr 8, 2026
Contributor
Author
|
Aborting because stats don't work for Go and Java: From @purple4reina ,
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Problem
PR #1118 (SVLS-8734) moved
_dd.compute_statsfrom each span'smetafield to the payload-level
tracer_payload.tagsmap only. This causedtrace stats such as
trace.aws.lambda.hitsto disappear from the trace explorer.The observed debug log that surfaced the issue:
Fix
_dd.compute_statsback intoChunkProcessor::process(), where it isset on each span's
metaalongside all other function tags. This restoresthe pre-feat(traces): [SVLS-8734] respect Datadog-Client-Computed-Stats header #1118 behavior regarding there the tag is set.
_dd.compute_statsfromtracer_payload.tags: it was never set therebefore feat(traces): [SVLS-8734] respect Datadog-Client-Computed-Stats header #1118 and is not needed.
ChunkProcessorgains aclient_computed_stats: boolfield (fromheader_tags); the"1"/"0"value is computed insideprocess()usingself.config.compute_trace_stats_on_extensionandself.client_computed_stats.Test plan
Automated tests
All 17 tests pass, including all 4
test_compute_stats_tag_*variants.Manual tests
Test 1: Missing trace stats issue is fixed
Steps
DD_COMPUTE_TRACE_STATS_ON_EXTENSIONorDD_TRACE_STATS_COMPUTATION_ENABLEDResult
In Metrics Explorer,
trace.aws.lambda.hitsshows 1 hit.Test 2: Duplicate trace stats issue is still fixed
Steps
github.com/DataDog/dd-trace-go/v2 v2.6.0DD_TRACE_STATS_COMPUTATION_ENABLED:true, which turns on client-side statsDD_COMPUTE_TRACE_STATS_ON_EXTENSION:true, which tries to turn on extension side statsResult
Still only 1 hit with

resource_name=dd-tracer-serverless-span, which means the double counting that #1118 was trying to fix is still fixed.Next steps
Once serverless-e2e-tests deployment is fixed, run the e2e tests and ensure trace stats look good.