feat(tracing): add span link support#330
Conversation
|
🎯 Code Coverage (details) 🔗 Commit SHA: 6c2f121 | Docs | Datadog PR Page | Give us feedback! |
BenchmarksBenchmark execution time: 2026-06-30 15:40:45 Comparing candidate commit 6c2f121 in PR branch Found 1 performance improvements and 0 performance regressions! Performance is the same for 7 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".
| if (!result) return result; | ||
|
|
||
| if (has_links) { | ||
| result = msgpack::pack_string(destination, "span_links"); |
There was a problem hiding this comment.
Preserve span links in the v0.4-compatible meta field
The library still sends traces to the Agent on /v0.4/traces (src/datadog/datadog_agent.cpp), but this change only emits links as a native top-level span_links field. Existing Datadog tracers also serialize links into meta["_dd.span_links"] as JSON for v0.4/collector compatibility; without that fallback, links can be ignored by agents or Datadog-compatible receivers that consume the v0.4 span meta representation, so users add links successfully but they do not show up after ingestion.
Useful? React with 👍 / 👎.
Description
Adds OpenTelemetry-style span links to dd-trace-cpp.
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