Skip to content

fix: forward trace-related OTEL env vars to Claude Code subprocess#1195

Open
jeanleeb wants to merge 3 commits intoanthropics:mainfrom
indigotech:fix/forward-otel-traces-env-vars
Open

fix: forward trace-related OTEL env vars to Claude Code subprocess#1195
jeanleeb wants to merge 3 commits intoanthropics:mainfrom
indigotech:fix/forward-otel-traces-env-vars

Conversation

@jeanleeb
Copy link
Copy Markdown

@jeanleeb jeanleeb commented Apr 8, 2026

Summary

PR #886 added forwarding for metrics/logs OTEL environment variables to the Claude Code subprocess, but missed several variables required for trace export and content detail:

Trace enablement (without these, no traces are exported):

  • CLAUDE_CODE_ENHANCED_TELEMETRY_BETA — required alongside CLAUDE_CODE_ENABLE_TELEMETRY to enable span tracing
  • OTEL_TRACES_EXPORTER — selects the traces exporter (e.g. otlp, console); without this, traces are not exported even when the endpoint is configured

Signal-specific transport (takes precedence over generic vars):

  • OTEL_EXPORTER_OTLP_TRACES_ENDPOINT — trace-specific endpoint URL (e.g. MLflow requires full /v1/traces path)
  • OTEL_EXPORTER_OTLP_TRACES_HEADERS — trace-specific headers (e.g. experiment routing)
  • OTEL_EXPORTER_OTLP_TRACES_PROTOCOL — trace-specific protocol override

Trace content detail (without these, traces arrive but are empty):

  • OTEL_LOG_TOOL_DETAILS — tool parameters in spans
  • OTEL_LOG_TOOL_CONTENT — full tool I/O content in spans (truncated at 60KB)
  • OTEL_LOG_USER_PROMPTS — user prompt text in spans

Without these, setting trace-related env vars in the workflow step's env: block has no effect because composite actions only forward explicitly listed variables (same root cause as #887).

Reproduction

- uses: anthropics/claude-code-action@v1
  env:
    CLAUDE_CODE_ENABLE_TELEMETRY: "1"
    CLAUDE_CODE_ENHANCED_TELEMETRY_BETA: "1"    # ❌ silently dropped
    OTEL_TRACES_EXPORTER: otlp                   # ❌ silently dropped
    OTEL_EXPORTER_OTLP_TRACES_ENDPOINT: https://mlflow.example.com/v1/traces  # ❌ dropped
    OTEL_EXPORTER_OTLP_TRACES_HEADERS: "x-mlflow-experiment-id=123"           # ❌ dropped
    OTEL_LOG_TOOL_DETAILS: "1"                   # ❌ silently dropped
    OTEL_LOG_TOOL_CONTENT: "1"                   # ❌ silently dropped
    OTEL_LOG_USER_PROMPTS: "1"                   # ❌ silently dropped

No traces are received at the OTLP endpoint despite all variables being set.

Changes

Added the 8 missing variables to the telemetry section of action.yml and base-action/action.yml, following the same ${{ env.VAR }} pattern used by existing telemetry variables.

Test plan

  • Verify bun test and bun run typecheck pass (no TS changes, YAML only)
  • Deploy with the fix and confirm OTEL traces arrive at the configured endpoint with full content

🤖 Generated with Claude Code

jeanleeb and others added 3 commits April 8, 2026 08:57
PR anthropics#886 added forwarding for metrics/logs OTEL variables but missed
three variables required for trace export:

- CLAUDE_CODE_ENHANCED_TELEMETRY_BETA: enables span tracing (required
  alongside CLAUDE_CODE_ENABLE_TELEMETRY for traces)
- OTEL_TRACES_EXPORTER: selects the traces exporter (e.g. "otlp")
- OTEL_LOG_TOOL_DETAILS: controls tool parameter detail in spans

Without these, setting trace-related env vars in the workflow step has
no effect because composite actions only forward explicitly listed vars.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The generic OTEL_EXPORTER_OTLP_ENDPOINT may not be picked up by
all OTEL SDK implementations. Adding the signal-specific variants
(OTEL_EXPORTER_OTLP_TRACES_ENDPOINT, _HEADERS, _PROTOCOL) ensures
traces reach the configured endpoint regardless of SDK behavior.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
These vars control the detail level of trace spans:
- OTEL_LOG_TOOL_CONTENT: includes full tool I/O in spans (truncated at 60KB)
- OTEL_LOG_USER_PROMPTS: includes user prompt text in spans

Without these, traces arrive but contain no meaningful content —
only timing and metadata.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant