Skip to content

Expose the trace's global tags and span defaults to serializers (OTLP trace/resource-level split) - #12960

Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 3 commits into
masterfrom
dougqh/otlp-metadata-tag-levels
Oct 23, 2026
Merged

gh-worker-dd-mergequeue-cf854d[bot] merged 3 commits into
masterfrom
dougqh/otlp-metadata-tag-levels

Conversation

@dougqh

@dougqh dougqh commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

What Does This Do

Adds two values to Metadata, the per-span object serializers receive:

  • getGlobalTags(): the trace's global tags (DD_TAGS, or their remote-config override, which keeps the configured env and version);
  • getSpanDefaultTags(): the trace's span defaults (DD_TRACE_SPAN_TAGS plus tracer-defined tags such as env), without the global tags. While a remote-config override is active, only the tracer-defined tags.

DDSpanContext fills both from the trace's config snapshot (TraceCollector.getTraceConfig()), using the maps #12937 added. Every span in a trace shares its collector's snapshot, so a config change mid-trace can't split one trace across two sets of global tags.

getTags() is unchanged and still includes both. Serializers that don't care about tag levels need no changes.

Motivation

This gets #12813 (OTLP) what it needs to write DD_TAGS once on the Resource instead of on every span, without reaching into TagMap internals or comparing values against the static Config:

  • Span attributes: the span's direct tags, plus getSpanDefaultTags() minus the keys the span sets itself;
  • Resource: getGlobalTags().

The encoder change itself stays with #12813.

The accessors are named for what the tags are, not where they come from. If trace-level state later moves to its own object (a trace segment), only DDSpanContext changes and serializers don't notice.

Additional Notes

  • Builds on Keep global tags apart from span defaults in the config snapshot (OTLP trace/resource-level split) #12937 and Add test for remote config tracing tags overriding DD_TAGS (OTLP trace/resource-level split) #12936, both merged. Rebased onto master, so the diff is only this PR's change.
  • Cost: two more references on each Metadata (one per serialized span, on the serializer thread) and one field read from the trace's snapshot. No change on the application thread.
  • Tests:
    • new CoreTracerTest.metadataCarriesTheTraceConfigTagLevels: a span started before a config change still serializes its trace's original maps (same instances);
    • existing Metadata constructor call sites in tests pass TagMap.EMPTY;
    • PayloadDispatcherImplTest builds a real DDSpanContext on a mocked PendingTrace whose default answer returned a null snapshot. It now returns a real one. In production the snapshot is never null: PendingTrace and StreamingTraceCollector fall back to captureTraceConfig().
  • Local runs:
    • dd-trace-core: the only failures are two Docker-based tests (no Docker locally) and two known timing tests (DDAgentWriterCombinedTest, PendingTraceBufferTest). Both timing tests pass when run on their own.
    • dd-trace-ot passes, and the traceAgentTest and jmh source sets compile.

🤖 Generated with Claude Code

@dougqh dougqh added comp: core Tracer core tag: no release notes Changes to exclude from release notes type: refactoring tag: ai generated Largely based on code generated by an AI or LLM labels Oct 20, 2026
@dougqh dougqh changed the title Expose the trace's global tags and span defaults to serializers Expose the trace's global tags and span defaults to serializers (OTLP trace/resource-level split) Oct 20, 2026
@dougqh
dougqh requested review from mcculls and mhlidd October 20, 2026 13:53
@datadog-official

This comment has been minimized.

@dd-octo-sts

dd-octo-sts Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

🟢 Java Benchmark SLOs — All performance SLOs passed

Suite Status
Startup 🟢 pass

SLO thresholds are defined here based on automatically generated metrics. A warning is raised when results are within 5% of the threshold.

PR vs. master results
Scenario Candidate master Δ (95% CI of mean)
startup:insecure-bank:iast:Agent 14.74 s 14.49 s [+0.7%; +2.7%] (maybe worse)
startup:insecure-bank:tracing:Agent 13.51 s 13.62 s [-1.6%; -0.0%] (maybe better)
startup:petclinic:appsec:Agent 17.71 s 17.60 s [-0.3%; +1.5%] (no difference)
startup:petclinic:iast:Agent 17.50 s 17.64 s [-1.5%; -0.0%] (maybe better)
startup:petclinic:profiling:Agent 17.28 s 16.87 s [-2.3%; +7.2%] (no difference)
startup:petclinic:sca:Agent 17.65 s 17.55 s [-0.2%; +1.5%] (no difference)
startup:petclinic:tracing:Agent 16.55 s 16.71 s [-2.1%; +0.2%] (no difference)

Commit: 017f6e62 · CI Pipeline · Benchmarking Platform UI


Load and DaCapo benchmarks can be triggered manually in the GitLab pipeline. Results will appear in the Benchmarking Platform UI after completion.

@mcculls mcculls left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The changes here make sense, building on the separation in the earlier PR

@dougqh
dougqh marked this pull request as ready for review October 22, 2026 20:18
@dougqh
dougqh requested a review from a team as a code owner October 22, 2026 20:18
@dougqh
dougqh requested review from ValentinZakharov and removed request for a team October 22, 2026 20:18
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-22T20:20:35.909108Z 709a142 Draft marked ready
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Base automatically changed from dougqh/split-global-span-tags to master October 22, 2026 20:21

@datadog-official datadog-official Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Bits Code Review: PASS

More details

The tag-level separation preserves span-default precedence, and serializers receive the trace collector’s captured maps, keeping each trace consistent across configuration changes.

Was this helpful? React 👍 or 👎

Open Bits AI session

🤖 Bits Code Review · Commit 709a142

dougqh and others added 3 commits October 22, 2026 22:18
Serializers get the global tags (DD_TAGS, or their remote-config
override) and the span defaults from the trace's config snapshot, so an
OTLP export can write the global tags once as resource attributes
instead of on every span. Both come from the snapshot the trace started
with, so a config change mid-trace can't split one trace across two sets.

getTags() is unchanged and still includes both.

Test call sites pass empty maps; PayloadDispatcherImplTest's mocked
PendingTrace now returns a real snapshot.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Also restores the Properties import the Metadata test still needs, which
#12937's switch to injectSysConfig dropped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dougqh
dougqh force-pushed the dougqh/otlp-metadata-tag-levels branch from 709a142 to 017f6e6 Compare October 23, 2026 02:28
@dougqh
dougqh enabled auto-merge October 23, 2026 02:38
@dougqh
dougqh added this pull request to the merge queue Oct 23, 2026
@dd-octo-sts

dd-octo-sts Bot commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

/merge

@gh-worker-devflow-routing-ef8351

gh-worker-devflow-routing-ef8351 Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

View all feedbacks in Devflow UI.

2026-10-23 03:18:57 UTC ℹ️ Start processing command /merge


2026-10-23 03:19:01 UTC ℹ️ MergeQueue: pull request added to the queue

The expected merge time in master is approximately 1h (p90).


2026-10-23 04:14:51 UTC ℹ️ MergeQueue: This merge request was merged

@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 23, 2026
@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot merged commit 17c1210 into master Oct 23, 2026
612 checks passed
@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot deleted the dougqh/otlp-metadata-tag-levels branch October 23, 2026 04:14
@github-actions github-actions Bot added this to the 1.68.0 milestone Oct 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp: core Tracer core tag: ai generated Largely based on code generated by an AI or LLM tag: no release notes Changes to exclude from release notes type: refactoring

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants