feat(tracing): add span link support#330
Conversation
|
🎯 Code Coverage (details) 🔗 Commit SHA: 5c93eca | Docs | Datadog PR Page | Give us feedback! |
BenchmarksBenchmark execution time: 2026-07-02 09:01:18 Comparing candidate commit 5c93eca in PR branch Found 2 performance improvements and 3 performance regressions! Performance is the same for 3 metrics, 0 unstable metrics.
|
cbb3ed8 to
86d189e
Compare
003399b to
28432fe
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1a36ade09f
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6c2f121762
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| const auto name = hdr[0].get<std::string>(); | ||
| if (name == "tracestate") { | ||
| ctx.tracestate = hdr[1].get<std::string>(); | ||
| } else if (name == "traceparent") { |
There was a problem hiding this comment.
Preserve header case-insensitivity when storing link context
When the parametric client passes valid HTTP headers with normal casing such as Traceparent, Tracestate, or X-Datadog-Sampling-Priority, extraction above succeeds because utils::HeaderReader::lookup lowercases names, but this new copy loop compares the raw JSON name only against lowercase literals. The stored link_contexts_ then loses flags/tracestate/sampling priority, so a later /trace/span/add_link emits an incomplete span link for the same extracted context.
Useful? React with 👍 / 👎.
8492993 to
5c93eca
Compare
Description
Adds OpenTelemetry-style span links to dd-trace-cpp.
ExtractedContext struct(include/datadog/extracted_context.h)SpanLinkstruct (include/datadog/span_link.h): 128-bittrace_id,span_id, optionaltracestate, stringattributes, optionalflags.src/datadog/span_link.cpp): per-link map with the exact field names and omission rules used by dd-trace-go / dd-trace-py / dd-trace-rs (trace_id,trace_id_highonly when non-zero,span_id,attributesonly when non-empty,tracestateonly when non-empty,flagswith high bit set when present).SpanData::span_links(src/datadog/span_data.h/.cpp):std::vector<SpanLink>field; the span encoder emits aspan_linksarray only when non-empty (matchesomitemptybehaviour of other tracers).Span::add_link(const SpanLink&)(include/datadog/span.h,src/datadog/span.cpp): public API to attach a link to a live span.POST /trace/span/add_link(test/system-tests/): wires up the cross-language system-test client contract.Motivation
This feature is supported by all other tracers and is a dependency for future implementations, such as
DD_TRACE_PROPAGATION_BEHAVIOR_EXTRACTconfig (planned).Additional Notes
test/test_span_link.cppandtest/test_span.cppexercise serialization and the public API end-to-end.Jira ticket: APMAPI-1941