feat: distributed tracing — nest Claude Code under an inbound TRACEPARENT#7
Draft
XinweiHe wants to merge 1 commit into
Draft
feat: distributed tracing — nest Claude Code under an inbound TRACEPARENT#7XinweiHe wants to merge 1 commit into
XinweiHe wants to merge 1 commit into
Conversation
…RENT Read W3C trace context from the environment (TRACEPARENT, and BAGGAGE) and parent the ask-root spans under it, so a backend that launches Claude Code (e.g. backend -> sandbox -> claude) gets ONE connected trace with the Claude Code session nested under the backend span. Standard OTEL propagation (OTEP-0258 env carriers). Fail-open: no/malformed TRACEPARENT -> fresh root trace, exactly as before. Baggage entries are stamped as traceroot.baggage.* attributes. Scoped per-process (each claude invocation reads its own env), so reused or parallel-flow sandboxes stay correctly separated. +4 tests (87 total). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Draft for review. Adds W3C trace-context propagation so a backend that launches Claude Code (e.g. backend → sandbox → Claude Code) gets one connected trace, with the Claude Code session nested under the backend span.
How
TRACEPARENT(andBAGGAGE) from the hook process's environment and parents the ask-root spans under it (sametrace_id).TRACEPARENTenv carrier is OTEP-0258; the backend builds it fromget_current_trace_id()/get_current_span_id().TRACEPARENT→ fresh root trace, exactly as today.traceroot.baggage.*attributes for correlation.claudeinvocation reads its own env, so reused/parallel-flow sandboxes stay separate (never a global).Verified
agent_taskspan →Claude Code Turn→ LLM → tools, all one trace.Notes for merge
TRACEPARENTin env (standard, but worth a glance).0.1.0 → 0.2.0.backend → sandbox → Claude Code) lives in the platform repo'sexamples/claude-code-distributed-tracing/.🤖 Generated with Claude Code