claude-code - 💡(How to fix) Fix [DOCS] Bash tool tracing docs missing `TRACEPARENT` subprocess propagation [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#45483Fetched 2026-04-09 08:04:22
View on GitHub
Comments
1
Participants
2
Timeline
5
Reactions
0
Author
Timeline (top)
labeled ×3closed ×1commented ×1
RAW_BUFFERClick to expand / collapse

Documentation Type

Missing documentation (feature not documented)

Documentation Location

https://code.claude.com/docs/en/monitoring-usage

Section/Topic

Traces (beta) and Bash subprocess tracing behavior

Current Documentation

The docs currently say:

Distributed tracing exports spans that link each user prompt to the API requests and tool executions it triggers, so you can view a full request as a single trace in your tracing backend.

Tracing is off by default. To enable it, set both CLAUDE_CODE_ENABLE_TELEMETRY=1 and CLAUDE_CODE_ENHANCED_TELEMETRY_BETA=1, then set OTEL_TRACES_EXPORTER to choose where spans are sent.

And the Bash tool reference says:

The Bash tool runs each command in a separate process with the following persistence behavior:

  • Working directory persists across commands. Set CLAUDE_BASH_MAINTAIN_PROJECT_WORKING_DIR=1 to reset to the project directory after each command.
  • Environment variables do not persist. An export in one command will not be available in the next.

No current page explains that, when tracing is enabled, Bash subprocesses receive a W3C TRACEPARENT environment variable.

What's Wrong or Missing?

Changelog v2.1.97 added: "Improved Bash tool OTEL tracing: subprocesses now inherit a W3C TRACEPARENT env var when tracing is enabled".

The current tracing documentation explains how to enable OpenTelemetry tracing, and the Bash tool documentation explains process behavior, but neither page documents that Bash commands receive TRACEPARENT or how users can use that value to correlate their own scripts and subprocesses with Claude Code traces.

That leaves an important tracing capability undiscoverable for users who want end-to-end trace propagation through shell scripts and command chains.

Suggested Improvement

Add a short subsection in Monitoring under Traces (beta) (and cross-reference it from Tools reference) that explains:

  • when tracing is enabled, Claude Code injects a W3C TRACEPARENT environment variable into Bash tool subprocesses
  • this lets user-run scripts and downstream instrumented processes attach to the same distributed trace
  • the variable is available per Bash command process rather than as a persisted shell export across turns

Include a minimal example such as reading TRACEPARENT inside a shell script or forwarding it to another traced process.

Impact

Medium - Makes feature difficult to understand

Additional Context

Affected Pages:

PageLine(s)Context
https://code.claude.com/docs/en/monitoring-usage107-119Tracing overview and enablement, but no subprocess trace-context propagation details
https://code.claude.com/docs/en/tools-reference52-59Bash process behavior and environment-variable behavior
https://code.claude.com/docs/en/env-vars181-200OpenTelemetry environment variable reference
https://code.claude.com/docs/en/agent-sdk/observability22-37, 140-147Agent SDK observability docs describe the same CLI tracing behavior

Total scope: 4 pages affected

Source: Changelog v2.1.97

Exact changelog entry: Improved Bash tool OTEL tracing: subprocesses now inherit a W3C TRACEPARENT env var when tracing is enabled

extent analysis

TL;DR

Add documentation to explain how Bash subprocesses receive a W3C TRACEPARENT environment variable when tracing is enabled, allowing users to correlate their scripts with Claude Code traces.

Guidance

  • Update the Traces (beta) section in the Monitoring documentation to include information about the TRACEPARENT environment variable injected into Bash tool subprocesses.
  • Add a cross-reference from the Tools reference page to the updated Traces (beta) section.
  • Include a minimal example in the documentation to demonstrate how to read the TRACEPARENT variable inside a shell script or forward it to another traced process.
  • Review the affected pages (listed in the Additional Context section) to ensure consistency in documentation.

Example

# Example of reading TRACEPARENT inside a shell script
echo "TRACEPARENT: $TRACEPARENT"

Notes

The suggested improvement should be applied to the specified pages to ensure that users can understand and utilize the tracing capability.

Recommendation

Apply workaround by adding the necessary documentation to the affected pages, as this will provide users with the required information to use the tracing feature effectively.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING