fix(otlp): propagate _dd.p.tid from chunk root to all spans#2014
Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 5 commits intoMay 29, 2026
Merged
Conversation
DD tracers set `_dd.p.tid` (high 64 bits of 128-bit trace ID) only on the chunk root per RFC #85 — the Datadog backend reconstructs the full 128-bit ID at ingest. The OTLP mapper previously read the tag per span, so children landed with upper 64 bits zeroed and traces fragmented in pure-OTel backends. Resolve the chunk-level `_dd.p.tid` once in `map_traces_to_otlp` and apply it to every span. Per-span value still wins (forward-compat with tracers that propagate everywhere). Use `find_map` over the chunk so a malformed root tag falls back to the first parseable value in the chunk rather than poisoning the whole trace. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
Clippy Allow Annotation ReportComparing clippy allow annotations between branches:
Summary by Rule
Annotation Counts by File
Annotation Stats by Crate
About This ReportThis report tracks Clippy allow annotations for specific rules, showing how they've changed in this PR. Decreasing the number of these annotations generally improves code quality. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2014 +/- ##
==========================================
+ Coverage 72.85% 72.91% +0.05%
==========================================
Files 459 459
Lines 76134 76315 +181
==========================================
+ Hits 55469 55645 +176
- Misses 20665 20670 +5
🚀 New features to boost your workflow:
|
🎉 All green!🧪 All tests passed 🎯 Code Coverage (details) 🔗 Commit SHA: 07196e6 | Docs | Datadog PR Page | Give us feedback! |
Contributor
Artifact Size Benchmark Reportaarch64-alpine-linux-musl
aarch64-unknown-linux-gnu
libdatadog-x64-windows
libdatadog-x86-windows
x86_64-alpine-linux-musl
x86_64-unknown-linux-gnu
|
…me calculated trace ID upper 64 bits on all spans in the chunk.
… trace_id field before checking the meta, in case we're already passing the full trace ID in.
mabdinur
approved these changes
May 26, 2026
paullegranddc
approved these changes
May 29, 2026
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.
What does this PR do?
This PR updates the conversion of DD spans to OTLP spans to ensure all spans receive the high 64 bits of the 128-bit trace ID.
DD tracers set
_dd.p.tid(high 64 bits of 128-bit trace ID) only on the chunk root per RFC #85 — the Datadog backend reconstructs the full 128-bit ID at ingest. The OTLP mapper previously only read the tag per span, so child spans were emitted with upper 64 bits zeroed and traces fragmented in pure-OTel backends.The approach determines the chunk-level
_dd.p.tidonce inmap_traces_to_otlpand applies it to every span in the chunk. Per-span value still wins (forward-compat with tracers that propagate everywhere). Usefind_mapover the chunk so a malformed root tag falls back to the first parseable value in the chunk rather than poisoning the whole trace.Motivation
Performing end-to-end tests with dd-trace-py exporting OTLP spans surfaced this issue, which results in child spans recording different trace IDs than the local root spans. Notably, the only difference was that the high 64-bits of the 128-bit trace ID were zero'ed out.
Additional Notes
A system-test to cover this scenario is being simultaneously added in DataDog/system-tests#6973
How to test the change?
Regression tests have been added to
libdd-trace-utils/src/otlp_encoder/mapper.rs.