[BUG] VS Code extension: no OTLP metrics emitted in SDK stream-json mode (likely same family as #46338)
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
The VS Code Claude Code extension (v2.1.112, Windows) correctly propagates OTEL_* / CLAUDE_CODE_ENABLE_TELEMETRY environment variables to its bundled claude.exe, but the bundled binary never emits OTLP metrics. As a result, VS Code-launched Claude sessions are invisible in our Grafana Cloud dashboard while Claude Desktop sessions (same user, same env vars) work perfectly.
We verified the env vars reach the bundled binary — this is not a config propagation bug. The bundled claude runs in SDK stream-json mode (--input-format stream-json --output-format stream-json), which appears to skip the OTLP exporter initialization that the interactive CLI performs.
Likely a sibling of the now-closed #46338 (OTel not emitting in -p mode). The VS Code extension spawns the bundled claude.exe with --input-format stream-json --output-format stream-json, which is architecturally adjacent to -p — another non-interactive entrypoint that appears to skip OTLP exporter initialization. Env var propagation to the child process is verified working (we instrumented with a wrapper), so this is not a config-reach bug. Also bears some symptom overlap with the open #46204 (silent OTel init failure on Windows), though the trigger is different (no enterprise-account detection involved here).
If #46338's fix was scoped to --print specifically, the same initialization path needs to extend to stream-json I/O mode.
What Should Happen?
When CLAUDE_CODE_ENABLE_TELEMETRY=1 and OTEL_EXPORTER_OTLP_* are set, the VS Code extension (or the bundled claude.exe it spawns) should emit the same OTLP metrics as Claude Desktop / the interactive CLI:
claude_code.session.count
claude_code.cost.usage
claude_code.token.usage
claude_code.lines_of_code.count
Error Messages/Logs
Steps to Reproduce
- Install VS Code Claude Code extension v2.1.112 on Windows 11.
- Set telemetry env vars at User scope:
[Environment]::SetEnvironmentVariable('CLAUDE_CODE_ENABLE_TELEMETRY', '1', 'User')
[Environment]::SetEnvironmentVariable('OTEL_METRICS_EXPORTER', 'otlp', 'User')
[Environment]::SetEnvironmentVariable('OTEL_EXPORTER_OTLP_PROTOCOL', 'http/json', 'User')
[Environment]::SetEnvironmentVariable('OTEL_EXPORTER_OTLP_ENDPOINT', 'http://127.0.0.1:4318', 'User')
[Environment]::SetEnvironmentVariable('OTEL_EXPORTER_OTLP_HEADERS', '', 'User')
- Run a local OTLP HTTP receiver on 127.0.0.1:4318 (any implementation — we used a Node stdlib script).
- Fully quit and reopen VS Code.
- Use Claude in VS Code (ask questions, make edits — at least a minute of activity).
- Observed: zero OTLP payloads arrive at the local receiver.
- For comparison, repeat with Claude Desktop — payloads arrive within seconds.
Evidence the env vars do reach the bundled binary: we built a C# wrapper placed at claudeCode.claudeProcessWrapper that logged its argv and environment before forwarding to the real claude.exe. All OTEL_ and CLAUDE_CODE_ vars were present in every spawn.
Evidence OTLP is emitted only by Desktop, never VS Code: during a mixed session, our inspector captured 39 OTLP payloads, all reporting service.version=2.1.111 (Desktop app build). The VS Code-bundled binary at %USERPROFILE%\.vscode\extensions\anthropic.claude-code-2.1.112-win32-x64\resources\native-binary\claude.exe reports version 2.1.112 — that version string appears in zero captured payloads.
Claude Model
None
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
VS Code extension: 2.1.112; Bundled binary: 2.1.112; Claude Desktop app (for comparison, works): 2.1.111
Platform
Anthropic API
Operating System
Windows
Terminal/Shell
Other
Additional Information
Hypothesis (for your triage): in extension.js, the env builder rj(K) correctly merges process.env into the spawn environment and sets CLAUDE_CODE_ENTRYPOINT=claude-vscode. The bundled claude.exe is then invoked in SDK mode with --input-format stream-json --output-format stream-json. In this mode the OTLP metrics exporter appears not to initialize (no network calls to the configured endpoint, no otel-related strings in extension.js host process either).
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗