[FEATURE] Custom OTEL_LOG_TOOL_CONTENT and OTEL_LOG_RAW_API_BODIES bodies truncation limit (60 KB)

Resolved 💬 1 comment Opened May 8, 2026 by everythings-gonna-be-alright Closed Jun 6, 2026

Preflight Checklist

  • [x] I have searched existing requests and this feature hasn't been requested yet
  • [x] 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.

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗