Skip to content

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-code

This 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

EventOTel NameData Collected
User promptclaude_code.user_promptPrompt text (if prompt capture enabled), session ID
API requestclaude_code.api_requestModel, input/output/cache tokens, cost, duration
Tool resultclaude_code.tool_resultTool name, success/failure, duration
API errorclaude_code.api_errorError 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=1 is set (or --prompts flag was used during install)
  • Token counts come from Claude's API response, not estimated

Flowstate Documentation