fix(ddtrace/tracer): wire version on aggregation key when adding a span to client-side stats#4737
Conversation
…an to client-side stats
🎉 All green!❄️ No new flaky tests detected 🎯 Code Coverage (details) 🔗 Commit SHA: ae6b9ab | Docs | Datadog PR Page | Give us feedback! |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files
🚀 New features to boost your workflow:
|
BenchmarksBenchmark execution time: 2026-05-11 16:11:49 Comparing candidate commit ae6b9ab in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 273 metrics, 2 unstable metrics, 1 flaky benchmarks without significant changes.
|
|
Admin-merging it because it was dogfooded in production. |
What does this PR do?
Port of #4734 to
main.ddtrace/tracer/stats.go— 3 changes1.
tracerStatSpangets aversionfieldThe struct that carries a finished span to the concentrator's goroutine now also carries whatever
versionmeta tag was on the span.2.
newTracerStatSpancapturesext.Versionfrom the span metaCalled on the hot path when a span finishes. Reads
s.meta["version"]— the same tag synthtracer sets viatracer.Tag("version", currentVersion()).3.
add()overrides the payload aggregation key version per-spanc.aggregationKeyis built once at startup withVersion = c.internalConfig.Version()(empty for synthtracer). Before this fix, every span used that frozen empty version →N/A. Now each span can carry its own version into a separate stats bucket, matching what the agent-side concentrator does when computing server-side stats.ddtrace/tracer/stats_test.go—TestPerSpanVersionInStatsThree sub-tests that pin the behaviour:
per-span version propagates to stats payloadversiontag →ClientStatsPayload.Versionmatches tag (was failing before fix)falls back to global config version when span has no version tagWithServiceVersion()/DD_VERSION(existing behaviour preserved)two spans with different versions produce separate payloads""(was failing before fix)Motivation
Ensure that stats are properly tagged with the version, both global and per-span.
Root cause:
Reviewer's Checklist
make lintlocally.make testlocally.make generatelocally.make fix-moduleslocally.Unsure? Have a question? Request a review!