[FEATURE] OTEL Tracing support for claude code using `--output-format stream-json --verbose`
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
We currently run a version of headless claude code using --print in a remote environment, and use --output-format stream-json --verbose to listen to the json event stream from claude code's output in order to stream back status to the caller.
When attempting to connect to our OTLP gateway, we discovered that if we specify --output-format stream-json we lose traces, where just a plain --print works fine and traces properly show up
Proposed Solution
I'd like to be able to use the tracing emitted by claude code (https://code.claude.com/docs/en/monitoring-usage#traces-beta) in conjunction with the --output-format stream-json parameters, without any additional changes.
Alternative Solutions
ATM our work around is to create manual traces ourselves by listening to the json logs which lacks much of the richer debugging information that the built in traces provide.
Priority
High - Significant impact on productivity
Feature Category
CLI commands and flags
Use Case Example
_No response_
Additional Context
_No response_