claude-code - 💡(How to fix) Fix [FEATURE] Custom OTEL_LOG_TOOL_CONTENT and OTEL_LOG_RAW_API_BODIES bodies truncation limit (60 KB)

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…

Fix Action

Fix / Workaround

OTEL_LOG_RAW_API_BODIES and OTEL_LOG_TOOL_CONTENT both apply a hardcoded 60 KB truncation limit on inline log payloads. This limit is not configurable, which creates friction for users whose OTEL backends support larger attribute values or who need full bodies for debugging without resorting to the file:<dir> workaround.

The file:<dir> workaround avoids truncation but splits the data across the filesystem and the OTEL pipeline, breaking unified querying in Grafana. It also violates 12-Factor App principles — specifically Factor XI (Logs), which mandates that logs are treated as event streams and never written to local disk by the application itself.

Code Example

OTEL_LOG_RAW_API_BODIES_MAX_BYTES=131072    # default: 61440 (60 KB), 0 = unlimited
OTEL_LOG_TOOL_CONTENT_MAX_BYTES=131072      # default: 61440 (60 KB), 0 = unlimited

---

CLAUDE_CODE_ENABLE_TELEMETRY=1
OTEL_LOGS_EXPORTER=otlp
OTEL_EXPORTER_OTLP_LOGS_ENDPOINT=http://localhost:4318/v1/logs
OTEL_LOG_RAW_API_BODIES=1
OTEL_LOG_RAW_API_BODIES_MAX_BYTES=524288   # 512 KB
RAW_BUFFERClick to expand / collapse

Preflight Checklist

  • I have searched existing requests and this feature hasn't been requested yet
  • This is a single feature request (not multiple features)

Problem Statement

OTEL_LOG_RAW_API_BODIES and OTEL_LOG_TOOL_CONTENT both apply a hardcoded 60 KB truncation limit on inline log payloads. This limit is not configurable, which creates friction for users whose OTEL backends support larger attribute values or who need full bodies for debugging without resorting to the file:<dir> workaround.

Current Behaviour

  • OTEL_LOG_RAW_API_BODIES=1 — bodies are truncated at 60 KB, silently
  • OTEL_LOG_TOOL_CONTENT=1 — tool content is truncated at 60 KB, silently
  • The only way to avoid truncation for API bodies is OTEL_LOG_RAW_API_BODIES=file:<dir>, which is unavailable for OTEL_LOG_TOOL_CONTENT

Proposed Solution

Introduce a new environment variable to let users override the truncation limit:

OTEL_LOG_RAW_API_BODIES_MAX_BYTES=131072    # default: 61440 (60 KB), 0 = unlimited
OTEL_LOG_TOOL_CONTENT_MAX_BYTES=131072      # default: 61440 (60 KB), 0 = unlimited

Priority

Medium - Would be very helpful

Feature Category

Other

Use Case Example

A team runs Claude Code with a self-hosted OpenTelemetry Collector and Grafana Loki as the log backend. They want to capture full Anthropic API request/response bodies for audit and debugging purposes. Their Loki instance accepts log entries up to 5 MB.

A typical multi-turn session with code context easily produces API bodies of 150–400 KB. With the hardcoded 60 KB cap, every api_request_body and api_response_body log event is silently truncated — the captured JSON is invalid (cut mid-token), and the logs are useless for replay or compliance review.

The file:<dir> workaround avoids truncation but splits the data across the filesystem and the OTEL pipeline, breaking unified querying in Grafana. It also violates 12-Factor App principles — specifically Factor XI (Logs), which mandates that logs are treated as event streams and never written to local disk by the application itself.

With the proposed variable

CLAUDE_CODE_ENABLE_TELEMETRY=1
OTEL_LOGS_EXPORTER=otlp
OTEL_EXPORTER_OTLP_LOGS_ENDPOINT=http://localhost:4318/v1/logs
OTEL_LOG_RAW_API_BODIES=1
OTEL_LOG_RAW_API_BODIES_MAX_BYTES=524288   # 512 KB

Full, valid JSON bodies are emitted inline as log events. The team can query, filter, and replay complete conversations directly from Loki without any out-of-band file references.

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