Repository navigation
Conversation
propagate_attributes(tags=..., as_baggage=True) sends tags as the Python list literal "['tag-a', 'tag-b']", because the W3C baggage propagator writes str(value). The receiving service set that string as langfuse.trace.tags instead of a list. Parse tags when reading them from baggage: a JSON array or a Python list literal, falling back to a comma split for the JS SDK's "tag-a,tag-b". The wire format is unchanged, since Langfuse's AI gateway already parses it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 22292d5)
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Fixes langfuse/langfuse#18379.
Draft / dependency: #1919 must land first (or its agreed tag decoder must be available). This branch cherry-picks Ambuj Upadhyay's #1919 commit
22292d5fe13e530a1deb89214e9b3b95ada18d0awith original authorship and acherry picked fromtrailer. The second commit is this PR's tag-merge change. I will update the branch against main once that dependency lands; this is not intended to replace #1919.After W3C baggage crosses a process boundary, adding local tags with
propagate_attributes(tags=[...])currently drops the inherited tags. The merge reads only the SDK's local context key, which is not restored by header extraction. In-process nesting already appends tags.This change seeds the merge from the existing
_get_propagated_attributes_from_context(context)reader. It reuses #1919's tag decoding and preserves the reader's precedence of local context over baggage. The existing append/dedup logic and wire format are unchanged.The regression tests cover:
as_baggage=False: merge locally, keep outgoing upstream baggage unchanged.as_baggage=True: send the merged tags to the next service.The
propagate_attributesdocstring now states the additive behavior. The JS counterpart is langfuse/langfuse-js#959 / langfuse/langfuse-js#966.Type of change
Verification
Python 3.12.14, Windows, OTel API/SDK 1.45.0. Commands used the existing locked development environment's Python interpreter, with
PYTHONPATHpointing at this isolated worktree:Lint, formatting of both changed files, and type checking passed. The test run reports one existing
set_trace_iodeprecation warning. An initial sandboxed baseline timed out while Windows asyncio created its socket pair; the baseline and final tests above passed outside that sandbox.I also reran an external three-process A -> B -> C localhost HTTP probe against the final source, using the real SDK with in-memory exporters. All hops kept the same trace ID:
memory, retrymemory, retryworker,as_baggage=Falsememory, retry, workermemory, retryworker,as_baggage=Truememory, retry, workermemory, retry, workerNo backend ingestion/UI e2e or live-provider tests were run; the defect and fix are observable at the SDK export boundary. The full unit suite was not run; verification focused on propagation and OTel tests.
Checklist
code_review.md..env.templateif needed. (Updated the public propagation docstring.)