claude-code - 💡(How to fix) Fix [DOCS] OpenTelemetry monitoring docs missing `OTEL_LOG_RAW_API_BODIES` configuration [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#49310Fetched 2026-04-17 08:44:53
View on GitHub
Comments
0
Participants
1
Timeline
3
Reactions
0
Author
Participants
Timeline (top)
labeled ×3

Error Message

OpenTelemetry configuration, API request/API error event reference, and security/privacy guidance for emitted content

  • error: Error message The current monitoring docs describe only three content-related opt-in variables (OTEL_LOG_USER_PROMPTS, OTEL_LOG_TOOL_DETAILS, and OTEL_LOG_TOOL_CONTENT) and the API request/error event sections do not explain whether raw request or response bodies can be emitted, where they appear, or what privacy/safety limits apply when this mode is enabled.
  1. Update the API request and API error event reference to explain which log events include raw request/response bodies when this variable is enabled. | https://code.claude.com/docs/en/monitoring-usage | 414-452 | API request and API error event sections enumerate attributes but do not describe raw request/response body emission |
RAW_BUFFERClick to expand / collapse

Documentation Type

Missing documentation (feature not documented)

Documentation Location

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

Section/Topic

OpenTelemetry configuration, API request/API error event reference, and security/privacy guidance for emitted content

Current Documentation

The docs currently say:

| OTEL_LOG_USER_PROMPTS | Enable logging of user prompt content (default: disabled) | 1 to enable | | OTEL_LOG_TOOL_DETAILS | Enable logging of tool parameters and input arguments in tool events and trace span attributes: Bash commands, MCP server and tool names, skill names, and tool input (default: disabled) | 1 to enable | | OTEL_LOG_TOOL_CONTENT | Enable logging of tool input and output content in span events (default: disabled). Requires tracing. Content is truncated at 60 KB | 1 to enable |

Event Name: claude_code.api_request

Attributes:

  • model: Model used (for example, "claude-sonnet-4-6")
  • cost_usd: Estimated cost in USD
  • duration_ms: Request duration in milliseconds
  • input_tokens: Number of input tokens
  • output_tokens: Number of output tokens
  • cache_read_tokens: Number of tokens read from cache
  • cache_creation_tokens: Number of tokens used for cache creation
  • speed: "fast" or "normal", indicating whether fast mode was active

Event Name: claude_code.api_error

Attributes:

  • model: Model used (for example, "claude-sonnet-4-6")
  • error: Error message
  • status_code: HTTP status code as a string, or "undefined" for non-HTTP errors
  • duration_ms: Request duration in milliseconds
  • attempt: Total number of attempts made, including the initial request (1 means no retries occurred)
  • speed: "fast" or "normal", indicating whether fast mode was active
  • User prompt content is not collected by default. Only prompt length is recorded. To include prompt content, set OTEL_LOG_USER_PROMPTS=1
  • Tool input arguments and parameters are not logged by default. To include them, set OTEL_LOG_TOOL_DETAILS=1.
  • Tool input and output content is not logged in trace spans by default. To include it, set OTEL_LOG_TOOL_CONTENT=1.

| OTEL_LOG_TOOL_CONTENT | Set to 1 to include tool input and output content in OpenTelemetry span events. Disabled by default to protect sensitive data. See Monitoring | | OTEL_LOG_TOOL_DETAILS | Set to 1 to include tool input arguments, MCP server names, and tool details in OpenTelemetry traces and logs. Disabled by default to protect PII. See Monitoring | | OTEL_LOG_USER_PROMPTS | Set to 1 to include user prompt text in OpenTelemetry traces and logs. Disabled by default (prompts are redacted). See Monitoring |

What's Wrong or Missing?

Changelog v2.1.111 added OTEL_LOG_RAW_API_BODIES to emit full API request and response bodies as OpenTelemetry log events for debugging, but the docs do not mention this environment variable anywhere in the Claude Code monitoring reference or environment variable reference.

The current monitoring docs describe only three content-related opt-in variables (OTEL_LOG_USER_PROMPTS, OTEL_LOG_TOOL_DETAILS, and OTEL_LOG_TOOL_CONTENT) and the API request/error event sections do not explain whether raw request or response bodies can be emitted, where they appear, or what privacy/safety limits apply when this mode is enabled.

That leaves users unable to discover the feature from the docs or understand how to enable it safely.

Suggested Improvement

Add OTEL_LOG_RAW_API_BODIES to the OpenTelemetry documentation in the same places that describe the other opt-in content variables.

Specifically:

  1. Add the variable to the configuration table on https://code.claude.com/docs/en/monitoring-usage.
  2. Update the API request and API error event reference to explain which log events include raw request/response bodies when this variable is enabled.
  3. Add security/privacy guidance covering whether bodies are redacted, truncated, or otherwise bounded, plus a warning that backends may need additional filtering.
  4. Add the variable to https://code.claude.com/docs/en/env-vars.
  5. If Agent SDK callers can pass this through, update https://code.claude.com/docs/en/agent-sdk/observability so the “Control sensitive data in exports” section stays aligned with the CLI monitoring docs.

Impact

Medium - Makes feature difficult to understand

Additional Context

Affected Pages:

PageLine(s)Context
https://code.claude.com/docs/en/monitoring-usage87-89OpenTelemetry configuration table lists the current content-related opt-in variables but omits OTEL_LOG_RAW_API_BODIES
https://code.claude.com/docs/en/monitoring-usage414-452API request and API error event sections enumerate attributes but do not describe raw request/response body emission
https://code.claude.com/docs/en/monitoring-usage606-608Security/privacy guidance says exported content is controlled by three opt-in variables
https://code.claude.com/docs/en/env-vars192-194Environment variable reference lists existing OpenTelemetry content variables but omits OTEL_LOG_RAW_API_BODIES
https://code.claude.com/docs/en/agent-sdk/observability189-197Agent SDK observability says only three opt-in variables add content to exported data

Total scope: 3 pages affected

Source: Changelog v2.1.111

Exact changelog entry:

Added OTEL_LOG_RAW_API_BODIES environment variable to emit full API request and response bodies as OpenTelemetry log events for debugging

extent analysis

TL;DR

Add OTEL_LOG_RAW_API_BODIES to the OpenTelemetry documentation to enable users to discover and safely use the feature for emitting full API request and response bodies as OpenTelemetry log events.

Guidance

  1. Update the configuration table: Add OTEL_LOG_RAW_API_BODIES to the OpenTelemetry configuration table on https://code.claude.com/docs/en/monitoring-usage to provide a clear reference for users.
  2. Explain raw request/response body emission: Update the API request and API error event reference sections to describe how raw request and response bodies are emitted when OTEL_LOG_RAW_API_BODIES is enabled.
  3. Add security/privacy guidance: Include information on whether bodies are redacted, truncated, or bounded, and warn users that backends may require additional filtering to protect sensitive data.
  4. Cross-reference with other documentation: Ensure consistency by updating https://code.claude.com/docs/en/env-vars and https://code.claude.com/docs/en/agent-sdk/observability to reflect the new environment variable and its implications.

Example

No specific code example is necessary for this documentation update, but the changelog entry provides a clear description of the new environment variable's purpose:

> Added `OTEL_LOG_RAW_API_BODIES` environment variable to emit full API request and response bodies as OpenTelemetry log events for debugging

Notes

The primary limitation of the current documentation is the lack of information about OTEL_LOG_RAW_API_BODIES, making it difficult for users to understand how to use this feature. Updating the documentation as suggested will improve usability and safety.

Recommendation

Apply the suggested improvements to the documentation to provide users with clear guidance on using OTEL_LOG_RAW_API_BODIES for debugging purposes. This will enhance the overall user experience and ensure that the feature is used safely and 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