claude-code - 💡(How to fix) Fix [DOCS] OpenTelemetry docs do not explain that subprocesses no longer inherit `OTEL_*` variables [1 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#56153Fetched 2026-05-05 05:56:48
View on GitHub
Comments
0
Participants
1
Timeline
3
Reactions
0
Author
Participants
Timeline (top)
labeled ×3
RAW_BUFFERClick to expand / collapse

Documentation Type

Incorrect/outdated documentation

Documentation Location

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

Section/Topic

"Traces (beta)" / subprocess trace propagation

Current Documentation

The monitoring page currently says:

When tracing is active, Bash and PowerShell subprocesses automatically inherit a TRACEPARENT environment variable containing the W3C trace context of the active tool execution span. This lets any subprocess that reads TRACEPARENT parent its own spans under the same trace, enabling end-to-end distributed tracing through scripts and commands that Claude runs.

And the hooks reference currently says:

Handlers run in the current directory with Claude Code's environment.

The Agent SDK observability page also says:

Configuration is passed as environment variables. By default, the child process inherits your application's environment, so you can configure telemetry in either of two places:

The CLI also forwards TRACEPARENT to every Bash and PowerShell command it runs. If a command launched through the Bash tool emits its own OpenTelemetry spans, those spans nest under the claude_code.tool.execution span that wraps the command.

What's Wrong or Missing?

A. The telemetry docs explain trace-context propagation but not exporter-config scrubbing

As of v2.1.128, Bash, hooks, MCP, and LSP subprocesses no longer inherit Claude Code's OTEL_* environment variables. That means an OTEL-instrumented child process no longer automatically picks up the CLI's own OTEL_EXPORTER_OTLP_ENDPOINT, headers, or related exporter settings.

B. Other pages still imply broader environment inheritance than users now get

The hooks reference says handlers run with Claude Code's environment, and the observability docs discuss subprocess trace linking through TRACEPARENT. Without an explicit note about OTEL_* scrubbing, readers can reasonably expect OTEL-instrumented subprocesses to export through the same collector automatically. After v2.1.128, they need their own OTEL exporter configuration if they should emit telemetry.

Suggested Improvement

Add a note to the monitoring page that distinguishes trace-context propagation from exporter configuration, for example:

Claude Code forwards W3C trace context (TRACEPARENT, and where applicable TRACESTATE) to supported subprocesses for parent/child trace linking, but subprocesses do not inherit Claude Code's OTEL_* exporter variables. If a Bash command, hook, MCP server, or LSP server should export its own OpenTelemetry data, configure its OTEL exporter environment explicitly.

Also add short cross-references from the hooks and Agent SDK observability pages so users do not infer that "inherits Claude Code's environment" includes Claude Code's own OTLP endpoint and exporter settings.

Impact

Medium - Makes feature difficult to understand

Additional Context

Affected Pages:

PageLine(s)Context
https://code.claude.com/docs/en/monitoring-usage120-124Documents TRACEPARENT propagation, but not that OTEL_* exporter variables are no longer inherited by subprocesses
https://code.claude.com/docs/en/hooks400Says hook handlers run with Claude Code's environment, which is now misleading for OTEL exporter configuration
https://code.claude.com/docs/en/agent-sdk/observability24-27, 161-165Explains environment inheritance into the CLI and TRACEPARENT forwarding, but not the subprocess OTEL_* limitation

Total scope: 3 pages affected

Version note: This gap matters for the v2.1.128 behavior change where subprocesses stop inheriting Claude Code's OTEL_* environment variables.

extent analysis

TL;DR

Update the documentation to clarify that subprocesses no longer inherit OTEL_* environment variables and require explicit OTEL exporter configuration.

Guidance

  • Add a note to the monitoring page to distinguish between trace-context propagation and exporter configuration.
  • Update the hooks reference page to remove the implication that handlers inherit Claude Code's environment for OTEL exporter configuration.
  • Add cross-references from the hooks and Agent SDK observability pages to the updated monitoring page for clarity.
  • Verify the changes by reviewing the affected pages and ensuring the new documentation accurately reflects the behavior change in v2.1.128.

Example

A possible update to the monitoring page could be:

Claude Code forwards W3C trace context (TRACEPARENT, and where applicable TRACESTATE) to supported subprocesses for parent/child trace linking, but subprocesses do not inherit Claude Code's OTEL_* exporter variables. If a Bash command, hook, MCP server, or LSP server should export its own OpenTelemetry data, configure its OTEL exporter environment explicitly.

Notes

The updates should focus on clarifying the behavior change in v2.1.128 and ensuring consistency across the affected pages.

Recommendation

Apply the suggested documentation updates to ensure accurate information and prevent user confusion about subprocess environment inheritance and OTEL exporter configuration.

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

claude-code - 💡(How to fix) Fix [DOCS] OpenTelemetry docs do not explain that subprocesses no longer inherit `OTEL_*` variables [1 participants]