Trace Claude Code CLI sessions, tool usage, and token costs with Arize AX for full observability.Claude Code is Anthropic’s agentic coding tool that lives in your terminal. The Arize Agent Kit instruments sessions using 9 hook events and sends OpenInference spans to Arize AX or Phoenix. The plugin works with both the Claude Code CLI and the Claude Agent SDK.
Launch Arize
To get started, sign up for a free Arize account and get your Space ID and API Key:- Log in at app.arize.com
- Click Settings and copy the Space ID
- Open the API Keys tab and create or copy an API key
Install
Claude Code Marketplace (recommended)
Curl installer
Manual (Agent SDK)
Clone the repository and point your Agent SDK project at the plugin directory:Configuration
Run the interactive setup after installation:- Ask whether to store tracing env vars globally in
~/.claude/settings.jsonor project-locally in.claude/settings.local.json - Ask which backend to configure: Phoenix or Arize AX
- Write the required env vars into the selected Claude settings file
- Optionally add
ARIZE_USER_IDfor span attribution
~/.claude/settings.json or .claude/settings.local.json:
Phoenix (self-hosted)
jq, curl. No Python needed.
Arize AX (cloud)
jq, curl, Python 3 with opentelemetry-proto and grpcio:
Restart Claude Code
Restart Claude Code for tracing to take effect:Observe
Now that you have tracing setup, all Claude Code sessions will be streamed to your Arize account for observability and evaluation. You’ll see:- Turn traces — each conversation turn (user prompt → assistant response)
- LLM spans — Claude’s responses with model info and token counts
- Tool spans — nested spans for each tool call with inputs, outputs, and duration
- Subagent spans — activity from any subagents Claude spawns
- Session grouping — all turns from the same session grouped by
session_id


Hooks Captured
| Hook | Span Kind | Description |
|---|---|---|
SessionStart | CHAIN | Session initialized, trace/tool counters reset |
UserPromptSubmit | CHAIN | User prompt captured (also lazy-inits session for SDK) |
PreToolUse | TOOL | Tool invocation started, records tool name and input |
PostToolUse | TOOL | Tool invocation completed, records output and duration |
Stop | LLM | Model response completed with input/output values |
SubagentStop | LLM | Subagent response completed |
Notification | CHAIN | System notification event |
PermissionRequest | CHAIN | Permission prompt for tool use |
SessionEnd | CHAIN | Session teardown, state file cleanup |
Agent SDK Compatibility
The plugin works with the Claude Agent SDK (Python) with one difference: the SDK does not fire aSessionStart event. The UserPromptSubmit hook performs lazy session initialization when it detects no prior session state.
Environment Variables
| Variable | Required | Default | Description |
|---|---|---|---|
ARIZE_TRACE_ENABLED | No | true | Enable or disable tracing |
ARIZE_API_KEY | For AX | - | Arize AX API key |
ARIZE_SPACE_ID | For AX | - | Arize AX space ID |
ARIZE_OTLP_ENDPOINT | No | otlp.arize.com:443 | OTLP gRPC endpoint (on-prem Arize) |
PHOENIX_ENDPOINT | For Phoenix | http://localhost:6006 | Phoenix collector URL |
PHOENIX_API_KEY | No | - | Phoenix API key (if auth enabled) |
ARIZE_PROJECT_NAME | No | Working dir basename | Project name in Arize/Phoenix |
ARIZE_USER_ID | No | - | User identifier added to all spans as user.id |
ARIZE_DRY_RUN | No | false | Print spans to log instead of sending |
ARIZE_VERBOSE | No | false | Enable verbose logging |
ARIZE_LOG_FILE | No | /tmp/arize-claude-code.log | Log file path (empty to disable) |
Troubleshooting
| Problem | Fix |
|---|---|
| Spans not appearing in Phoenix | Verify Phoenix is running (curl -s http://localhost:6006/healthz), check PHOENIX_ENDPOINT and ARIZE_TRACE_ENABLED |
| Spans not appearing in Arize AX | Check ARIZE_API_KEY and ARIZE_SPACE_ID, ensure Python deps (python3 -c "import opentelemetry; import grpc") |
jq required error | Install jq: brew install jq (macOS) or apt-get install jq (Linux) |
| No output in terminal | Hook stderr is discarded; check /tmp/arize-claude-code.log |
| Want to test without sending | Set ARIZE_DRY_RUN to "true" |
| Want verbose logging | Set ARIZE_VERBOSE to "true" |
| User ID not appearing on spans | Verify ARIZE_USER_ID is set in .claude/settings.local.json under the env key |
| Session state issues | Remove stale state: rm -rf ~/.arize-claude-code/state_*.json |