Observability for Claude Agent SDK with Opik
Claude Code telemetry is configured through environment variables.
When this guide applies
Use this guide when you want to configure Claude Code’s official OpenTelemetry settings and align endpoint/header values with your Opik deployment mode.
Claude Code’s monitoring docs currently describe OTel metrics and events/logs exporters. Opik tracing views are span-based. Verify your pipeline emits spans if your goal is trace visualization in Opik.
Opik OTLP endpoint modes
For full endpoint/header details, see Opik OpenTelemetry overview.
Opik Cloud
Enterprise deployment
Self-hosted instance
Required headers:
AuthorizationComet-Workspace
Optional headers:
projectName(recommended for deterministic routing)
Claude telemetry configuration (official pattern)
Intent: Enable Claude Code telemetry and route supported OTel signals to your collector/backend.
Applies when: You run Claude Code with telemetry enabled via environment variables.
Required fields:
CLAUDE_CODE_ENABLE_TELEMETRY=1- at least one exporter (
OTEL_METRICS_EXPORTERorOTEL_LOGS_EXPORTER)
Optional fields:
OTEL_EXPORTER_OTLP_PROTOCOLOTEL_EXPORTER_OTLP_ENDPOINTOTEL_EXPORTER_OTLP_HEADERS- per-signal overrides such as
OTEL_EXPORTER_OTLP_METRICS_ENDPOINT
Minimal valid setup:
Validation
- Start Claude with telemetry enabled.
- Confirm your OTLP backend receives
claude_code.*metrics/events. - If targeting Opik trace views, verify spans are emitted by your pipeline; metrics/logs alone will not appear as traces.