Skip to content

[BUG] OpenTelemetry not working when Claude Code runs in VS Code extension (pipe/stream-json mode) #35105

Description

@bellowswang

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • I am using the latest version of Claude Code

What's Wrong?

Terminal claude code would export OTEL data without any problem.
VS Code Panel/Sidebar claude code wouldn't be able to export any OTEL data.
~/.claude/settings.json and claudeCode.environmentVariables are correctly configured.
It might not only be about vs code. It's a general issue in the pipe/stream-json mode.

What Should Happen?

Even if it's in the pipe/stream-json mode, it should export OTEL data based on the configurations in settings.json

Error Messages/Logs

Steps to Reproduce

Configure OpenTelemetry in ~/.claude/settings.json:

{
"env": {
"CLAUDE_CODE_ENABLE_TELEMETRY": "1",
"OTEL_METRICS_EXPORTER": "otlp",
"OTEL_LOGS_EXPORTER": "otlp",
"OTEL_EXPORTER_OTLP_PROTOCOL": "grpc",
"OTEL_EXPORTER_OTLP_ENDPOINT": "http://localhost:4317"
}
}
Also configure in VS Code settings.json:

{
"claudeCode.environmentVariables": [
{ "name": "CLAUDE_CODE_ENABLE_TELEMETRY", "value": "1" },
{ "name": "OTEL_METRICS_EXPORTER", "value": "otlp" },
{ "name": "OTEL_LOGS_EXPORTER", "value": "otlp" },
{ "name": "OTEL_EXPORTER_OTLP_PROTOCOL", "value": "grpc" },
{ "name": "OTEL_EXPORTER_OTLP_ENDPOINT", "value": "http://localhost:4317" }
]
}
Start an OTEL collector listening on localhost:4317 (e.g. via otel-desktop-viewer, Jaeger, or any OTLP-compatible collector)

Open a terminal and run claude, send a message — OTEL data is received by the collector ✅

Open VS Code, use Claude Code in the panel/sidebar, send a message — No OTEL data received ❌

Claude Model

None

Is this a regression?

I don't know

Last Working Version

No response

Claude Code Version

2.1.76

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Other

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghas reproHas detailed reproduction stepsplatform:macosIssue specifically occurs on macOSplatform:vscodeIssue specifically occurs in VS CodestaleIssue is inactive

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions