Skip to content

fix(tracer): skip JSON span-links serialization when using v1 protocol#4573

Merged
darccio merged 2 commits into
mainfrom
dario.castane/langplat-59/avoid-double-spanlinks
Mar 24, 2026
Merged

fix(tracer): skip JSON span-links serialization when using v1 protocol#4573
darccio merged 2 commits into
mainfrom
dario.castane/langplat-59/avoid-double-spanlinks

Conversation

@darccio

@darccio darccio commented Mar 20, 2026

Copy link
Copy Markdown
Member

What does this PR do?

Adds a supportsLinks bool field to Span (mirroring supportsEvents) and guards serializeSpanLinksInMeta() so it becomes a no-op when the v1 protocol encoder is active.

When the tracer uses the v1 protocol, span links are encoded as a native first-class field (field 11 of the span map). serializeSpanLinksInMeta() was called unconditionally at finish() time, so links were also serialized as a JSON string under meta["_dd.span_links"] and re-emitted in the span attributes array. This caused every span with links to carry them twice in the v1 payload.

The pattern mirrors how serializeSpanEvents() handles the same problem for span events via supportsEvents.

Motivation

Identified as a misalignment between the v1 protocol's invariants and the tracer's finish-time serialization path. The v1 encoder handles span links natively; the JSON fallback path existed for agents that predate native span-link support in the msgp (v04) format and must be preserved for that path.

Reviewer's Checklist

  • Changed code has unit tests for its functionality at or near 100% coverage.
  • New code is free of linting errors. You can check this by running make lint locally.
  • New code doesn't break existing tests. You can check this by running make test locally.
  • All generated files are up to date. You can check this by running make generate locally.

@darccio
darccio requested review from a team as code owners March 20, 2026 14:03
@darccio

darccio commented Mar 20, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Nice work!

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@datadog-prod-us1-5

datadog-prod-us1-5 Bot commented Mar 20, 2026

Copy link
Copy Markdown

✅ Tests

🎉 All green!

❄️ No new flaky tests detected
🧪 All tests passed

🎯 Code Coverage (details)
Patch Coverage: 100.00%
Overall Coverage: 59.89% (+0.09%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: ea28b20 | Docs | Datadog PR Page | Was this helpful? React with 👍/👎 or give us feedback!

@pr-commenter

pr-commenter Bot commented Mar 20, 2026

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2026-03-24 08:54:45

Comparing candidate commit ea28b20 in PR branch dario.castane/langplat-59/avoid-double-spanlinks with baseline commit 5ff9ae4 in branch main.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 217 metrics, 7 unstable metrics.

Explanation

This is an A/B test comparing a candidate commit's performance against that of a baseline commit. Performance changes are noted in the tables below as:

  • 🟩 = significantly better candidate vs. baseline
  • 🟥 = significantly worse candidate vs. baseline

We compute a confidence interval (CI) over the relative difference of means between metrics from the candidate and baseline commits, considering the baseline as the reference.

If the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD), the change is considered significant.

Feel free to reach out to #apm-benchmarking-platform on Slack if you have any questions.

More details about the CI and significant changes

You can imagine this CI as a range of values that is likely to contain the true difference of means between the candidate and baseline commits.

CIs of the difference of means are often centered around 0%, because often changes are not that big:

---------------------------------(------|---^--------)-------------------------------->
                              -0.6%    0%  0.3%     +1.2%
                                 |          |        |
         lower bound of the CI --'          |        |
sample mean (center of the CI) -------------'        |
         upper bound of the CI ----------------------'

As described above, a change is considered significant if the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD).

For instance, for an execution time metric, this confidence interval indicates a significantly worse performance:

----------------------------------------|---------|---(---------^---------)---------->
                                       0%        1%  1.3%      2.2%      3.1%
                                                  |   |         |         |
       significant impact threshold --------------'   |         |         |
                      lower bound of CI --------------'         |         |
       sample mean (center of the CI) --------------------------'         |
                      upper bound of CI ----------------------------------'

@codecov

codecov Bot commented Mar 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 60.49%. Comparing base (5ff9ae4) to head (ea28b20).

Additional details and impacted files
Files with missing lines Coverage Δ
ddtrace/tracer/span.go 85.07% <100.00%> (-4.26%) ⬇️
ddtrace/tracer/tracer.go 88.35% <100.00%> (-3.87%) ⬇️

... and 265 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@kakkoyun kakkoyun left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀

@darccio
darccio merged commit 520f825 into main Mar 24, 2026
203 of 206 checks passed
@darccio
darccio deleted the dario.castane/langplat-59/avoid-double-spanlinks branch March 24, 2026 08:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants