feat(baggage): add support for baggage span tags#223
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 05f787b853
ℹ️ 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".
| for kv in baggage_span_tags(parent_ctx.baggage(), self.config.trace_baggage_tag_keys()) | ||
| { | ||
| span.set_attribute(kv); |
There was a problem hiding this comment.
Promote baggage tags on baggage-only root spans
When an incoming request carries only a baggage header (or a local root span is started with baggage) and no valid remote trace context, extract_with_context still attaches the baggage to parent_ctx, but this loop only runs inside the is_remote() branch. That makes DD_TRACE_BAGGAGE_TAG_KEYS silently ineffective for baggage-only propagation, even though this change adds baggage as a supported propagation style; the local-root path should also apply these baggage span tags.
Useful? React with 👍 / 👎.
|
✨ Fix all issues with BitsAI or with Cursor
|
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Per W3C Baggage spec, a malformed member invalidates the rest of the header. Change extraction to stop on the first unparseable entry (including entries with empty keys or values) rather than skipping and continuing. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1dd94661a4
ℹ️ 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".
W3C Baggage spec defines value = *baggage-octet (zero or more), so empty values are valid. Only empty keys are truly malformed (key = 1*tchar requires at least one character). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
An input like "," or ", ," produces an empty key list after filtering, which behaves identically to Disabled. Normalize it explicitly so Keys always contains at least one entry. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Empty values are valid per W3C spec (value = *baggage-octet), so this test case that was removed when we incorrectly rejected empty values should be present. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ced default Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
A ST is failing because it expects all items get dropped if a value is missing 🙃 |
Points to the updated test_baggage_span_tags_malformed_header which uses an empty key (=doggo,...) as the malformed case, per W3C spec (empty values are valid, only empty keys are not). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
What does this PR do?
Implements the
DD_TRACE_BAGGAGE_TAG_KEYSfeature, which automatically promotes W3C Baggage entries to span tags at extraction time.When a span is created with a remote parent, baggage entries matching the configured filter are attached as span attributes prefixed with
baggage.:Tags are only applied at extraction time, not to locally-created root spans.
Baggage Tagging Behavior
""(empty): Disabled — no baggage keys become span tags"*": All baggage keys are tagged"user.id,session.id": Only the listed keys are taggedW3C spec compliance fix
Per the W3C Baggage spec, a malformed member (empty key, empty value, or missing =) must cause all subsequent members to be dropped — not just the malformed one. This PR fixes the extraction to use stop-at-first-error semantics instead of skip-and-continue.
Configuration
DD_TRACE_BAGGAGE_TAG_KEYSMotivation
What inspired you to submit this pull request?
Additional Notes
Anything else we should know when reviewing?