Appearance
Claude Code
Claude Code has native OpenTelemetry support, making it one of the easiest tools to configure.
Automatic Setup
bash
flowstate-telemetry install --tool claude-codeThis adds the OTel environment variables to the env block in ~/.claude/settings.json.
Manual Setup
Add the following to your ~/.claude/settings.json in the env block:
json
{
"env": {
"OTEL_EXPORTER_OTLP_ENDPOINT": "https://otel.flowstate.inc",
"OTEL_EXPORTER_OTLP_HEADERS": "x-flowstate-key=YOUR_TELEMETRY_KEY"
}
}To also enable prompt capture, add:
json
{
"env": {
"OTEL_EXPORTER_OTLP_ENDPOINT": "https://otel.flowstate.inc",
"OTEL_EXPORTER_OTLP_HEADERS": "x-flowstate-key=YOUR_TELEMETRY_KEY",
"OTEL_LOG_USER_PROMPTS": "1"
}
}What Gets Captured
| Event | OTel Name | Data Collected |
|---|---|---|
| User prompt | claude_code.user_prompt | Prompt text (if prompt capture enabled), session ID |
| API request | claude_code.api_request | Model, input/output/cache tokens, cost, duration |
| Tool result | claude_code.tool_result | Tool name, success/failure, duration |
| API error | claude_code.api_error | Error details |
TIP
Claude Code sends rich session metadata including file paths, lines added/removed, and git context — making project attribution highly accurate.
Limitations
- Prompt text is only captured if
OTEL_LOG_USER_PROMPTS=1is set (or--promptsflag was used during install) - Token counts come from Claude's API response, not estimated