Skip to content

refactor(propagation): Parse OpenTelemetry tracestate member - #12405

Open
MilanGarnier wants to merge 15 commits into
masterfrom
milan.garnier/otel-tracestate-refactor
Open

refactor(propagation): Parse OpenTelemetry tracestate member#12405
MilanGarnier wants to merge 15 commits into
masterfrom
milan.garnier/otel-tracestate-refactor

Conversation

@MilanGarnier

Copy link
Copy Markdown
Contributor

What Does This Do

Refactors W3C tracestate handling so the OpenTelemetry ot member is
represented separately while its value remains opaque.

  • Extracts and re-emits the raw ot member.
  • Preserves its inherited position when rebuilding tracestate.
  • Does not interpret rv or th or connect the member to sampling.

Motivation

Isolate the tracestate parsing foundation from the consistent-sampling
behavior added by the follow-up PR.

Additional Notes

This is the first PR in a two-PR stack. The sampling behavior follows in
#12397.

Validation:

  • :dd-trace-core:compileJava
  • :dd-trace-core:spotlessCheck
  • git diff --check

Contributor Checklist

  • Format the title according to the contribution guidelines.
  • Assign the required type: and comp: labels.
  • Keep sampling behavior and tests in the follow-up PR.

Jira ticket: APMAPI-2171

@datadog-datadog-prod-us1

This comment has been minimized.

@dd-octo-sts

dd-octo-sts Bot commented Sep 4, 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 13.98 s 14.02 s [-1.2%; +0.7%] (no difference)
startup:insecure-bank:tracing:Agent 12.97 s 13.02 s [-1.2%; +0.5%] (no difference)
startup:petclinic:appsec:Agent 17.60 s 17.53 s [-0.3%; +1.2%] (no difference)
startup:petclinic:iast:Agent 17.35 s 17.55 s [-1.9%; -0.4%] (maybe better)
startup:petclinic:profiling:Agent 17.41 s 17.12 s [+0.6%; +2.9%] (maybe worse)
startup:petclinic:sca:Agent 17.71 s 17.51 s [+0.0%; +2.3%] (maybe worse)
startup:petclinic:tracing:Agent 16.56 s 16.15 s [-1.9%; +6.8%] (no difference)

Commit: a6910415 · 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.

@MilanGarnier
MilanGarnier marked this pull request as ready for review September 4, 2026 16:07
@MilanGarnier
MilanGarnier requested a review from a team as a code owner September 4, 2026 16:07
@MilanGarnier
MilanGarnier requested review from mcculls and removed request for a team September 4, 2026 16:07

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 397a1ff69a

ℹ️ 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".

@datadog-datadog-prod-us1 datadog-datadog-prod-us1 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.

Datadog Autotest: PASS

More details

The change keeps the raw ot member and its inherited position when it rebuilds tracestate. The static review finds no reportable regression in the changed parsing and serialization paths.

Was this helpful? React 👍 or 👎

Open Bits AI session

🤖 Datadog Autotest · Commit 397a1ff · What is Autotest? · @DataDog review to ask questions · Any feedback? Reach out in #autotest

mcculls
mcculls previously requested changes Sep 4, 2026

@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 double-parsing issue will need to be fixed before this can be merged.

Claude suggests giving PTags a way to accept an already-built OtelTraceState directly (e.g. setOtelTraceState), and have applyTraceContextToFirstContext pass the parsed object from traceContext.getPropagationTags() instead of round-tripping through the string.

The double-counting issue is easily solved by removing the second addition.

@MilanGarnier
MilanGarnier requested a review from mcculls September 7, 2026 12:07
@mcculls
mcculls dismissed their stale review September 8, 2026 16:12

Dismissing stale review

@MilanGarnier
MilanGarnier force-pushed the milan.garnier/otel-tracestate-refactor branch from db321c0 to 1c02400 Compare September 10, 2026 09:02
@MilanGarnier
MilanGarnier force-pushed the milan.garnier/otel-tracestate-refactor branch from 61e502b to 2bc71c1 Compare September 11, 2026 13:54
@MilanGarnier
MilanGarnier force-pushed the milan.garnier/otel-tracestate-refactor branch from b6c0c9a to 074cb0d Compare September 11, 2026 14:06
@MilanGarnier
MilanGarnier force-pushed the milan.garnier/otel-tracestate-refactor branch from dad360e to c7a64c3 Compare September 11, 2026 14:21
@MilanGarnier MilanGarnier removed the tag: ai generated Largely based on code generated by an AI or LLM label Sep 11, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

The core round-trip behavior lacks coverage, and parsing introduces an avoidable hot-path allocation.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Separates the OpenTelemetry ot tracestate member for future sampling support while preserving its opaque value and position.

Changes:

  • Extracts and stores ot member metadata.
  • Re-emits ot in its inherited position.
  • Copies parsed state across propagation contexts.
File summaries
File Description
OtelTraceStateParsingTest.java Tests the new state container.
W3CPTagsCodec.java Extracts and rebuilds ot members.
PTagsFactory.java Stores and transfers parsed state.
OtelTraceState.java Defines the opaque state representation.
PropagationTags.java Adds state-copying API.
HttpCodec.java Uses state-aware copying during extraction.
Review details
  • Files reviewed: 6/6 changed files
  • Comments generated: 2
  • Review effort level: Balanced

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +21 to +23
void retainsValueAndMemberMetadata() {
OtelTraceState state =
OtelTraceState.parse(VALUE, INHERITED_POSITION, ORIGINAL_MEMBER_CONTRIBUTION_SIZE);
@mcculls

mcculls commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Note the new muzzle failure happens on master too - it will be unblocked once #12478 is merged

@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.

I think this is ready to be merged now - thanks for the continual improvements to this PR, and the extra tests.

Note I'm going to add a task to revisit this parser in the future to think about ways it could be refactored to simplify the overall structure/logic, but that's separate to this feature

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants