Overview
Claude Code monitoring with OpenTelemetry gives you full visibility into how Claude is used across your engineering team. This guide walks you through exporting Claude Code logs and metrics to SigNoz, so you can track the signals that matter most:
- Token usage & costs — break down spend by user, model, or subagent
- Session & request activity — track adoption, active time, and request volumes
- Performance — monitor API latency, cache hit rates, and tool execution times
- Quota & limits — stay ahead of rate limits before they impact developers
- Tool decisions — see accept/reject rates across Edit, Write, and other tools
- Errors & retries — detect API failures and retry exhaustion before they snowball
Once set up, all of this flows into SigNoz dashboards where you can correlate logs and metrics, set alerts, and analyze trends over time.
Prerequisites
- SigNoz setup (choose one):
- SigNoz Cloud account with an active ingestion key
- Self-hosted SigNoz instance
- Internet access to send telemetry data to SigNoz Cloud
- Claude Code installed and running on your system
Monitoring Claude Code
Check out detailed instructions on how to set up OpenTelemetry instrumentation for your Claude Code usage in the Claude Code monitoring docs. Every variable used below is listed in the Environment Variable Reference.
Option 1 (VSCode)
Step 1: Launch VSCode with telemetry enabled
CLAUDE_CODE_ENABLE_TELEMETRY=1 \
OTEL_METRICS_EXPORTER=otlp \
OTEL_LOGS_EXPORTER=otlp \
OTEL_EXPORTER_OTLP_PROTOCOL=grpc \
OTEL_EXPORTER_OTLP_ENDPOINT="https://ingest.<region>.signoz.cloud:443" \
OTEL_EXPORTER_OTLP_HEADERS="signoz-ingestion-key=<your-ingestion-key>" \
OTEL_METRIC_EXPORT_INTERVAL=10000 \
OTEL_LOGS_EXPORT_INTERVAL=5000 \
code .<region>: Your SigNoz Cloud region<your-ingestion-key>: Your SigNoz ingestion key
This will open VSCode with the required environment variables already configured. From here, any Claude Code activity will automatically generate telemetry and export logs to your SigNoz Cloud instance.
For convenience, you can also clone our bash script, update it with your SigNoz endpoint and ingestion key, and run it directly.
Option 2 (Terminal)
Step 1: Launch Claude Code with telemetry enabled
CLAUDE_CODE_ENABLE_TELEMETRY=1 \
OTEL_METRICS_EXPORTER=otlp \
OTEL_LOGS_EXPORTER=otlp \
OTEL_EXPORTER_OTLP_PROTOCOL=grpc \
OTEL_EXPORTER_OTLP_ENDPOINT="https://ingest.<region>.signoz.cloud:443" \
OTEL_EXPORTER_OTLP_HEADERS="signoz-ingestion-key=<your-ingestion-key>" \
OTEL_METRIC_EXPORT_INTERVAL=10000 \
OTEL_LOGS_EXPORT_INTERVAL=5000 \
claude- Set the
<region>to match your SigNoz Cloud region - Replace
<your-ingestion-key>with your SigNoz ingestion key
This will launch Claude Code with telemetry enabled. Any Claude Code activity in the terminal session will automatically generate and export logs and metrics to your SigNoz Cloud instance.
For convenience, you can also clone our bash script, update it with your SigNoz endpoint and ingestion key, and run it directly.
Administrator Configuration
Administrators can configure OpenTelemetry settings for all users through the managed settings file. This allows for centralized control of telemetry settings across an organization. See the settings precedence for more information about how settings are applied.
The managed settings file is located at:
- macOS:
/Library/Application Support/ClaudeCode/managed-settings.json - Linux and WSL:
/etc/claude-code/managed-settings.json - Windows:
C:\ProgramData\ClaudeCode\managed-settings.json
Example managed settings configuration:
{
"env": {
"CLAUDE_CODE_ENABLE_TELEMETRY": "1",
"OTEL_METRICS_EXPORTER": "otlp",
"OTEL_LOGS_EXPORTER": "otlp",
"OTEL_EXPORTER_OTLP_PROTOCOL": "grpc",
"OTEL_EXPORTER_OTLP_ENDPOINT": "http://collector.company.com:4317",
"OTEL_EXPORTER_OTLP_HEADERS": "Authorization=Bearer company-token"
}
}Managed settings can be distributed via MDM (Mobile Device Management) or other device management solutions. Environment variables defined in the managed settings file have high precedence and cannot be overridden by users.
Example Configurations
# Console debugging (1-second intervals)
export CLAUDE_CODE_ENABLE_TELEMETRY=1
export OTEL_METRICS_EXPORTER=console
export OTEL_METRIC_EXPORT_INTERVAL=1000
# OTLP/gRPC
export CLAUDE_CODE_ENABLE_TELEMETRY=1
export OTEL_METRICS_EXPORTER=otlp
export OTEL_EXPORTER_OTLP_PROTOCOL=grpc
export OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317
# Prometheus
export CLAUDE_CODE_ENABLE_TELEMETRY=1
export OTEL_METRICS_EXPORTER=prometheus
# Multiple exporters
export CLAUDE_CODE_ENABLE_TELEMETRY=1
export OTEL_METRICS_EXPORTER=console,otlp
export OTEL_EXPORTER_OTLP_PROTOCOL=http/json
# Different endpoints/backends for metrics and logs
export CLAUDE_CODE_ENABLE_TELEMETRY=1
export OTEL_METRICS_EXPORTER=otlp
export OTEL_LOGS_EXPORTER=otlp
export OTEL_EXPORTER_OTLP_METRICS_PROTOCOL=http/protobuf
export OTEL_EXPORTER_OTLP_METRICS_ENDPOINT=http://metrics.company.com:4318
export OTEL_EXPORTER_OTLP_LOGS_PROTOCOL=grpc
export OTEL_EXPORTER_OTLP_LOGS_ENDPOINT=http://logs.company.com:4317
# Metrics only (no events/logs)
export CLAUDE_CODE_ENABLE_TELEMETRY=1
export OTEL_METRICS_EXPORTER=otlp
export OTEL_EXPORTER_OTLP_PROTOCOL=grpc
export OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317
# Events/logs only (no metrics)
export CLAUDE_CODE_ENABLE_TELEMETRY=1
export OTEL_LOGS_EXPORTER=otlp
export OTEL_EXPORTER_OTLP_PROTOCOL=grpc
export OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317Your Claude Code activity should now automatically emit logs and metrics.
Finally, you should be able to view logs in Signoz Cloud under the logs tab:

When you click on any of these logs in SigNoz, you'll see a detailed view of the log, including attributes:




You should be able to see Claude Code related metrics in Signoz Cloud under the metrics tab:

When you click on any of these metrics in SigNoz, you'll see a detailed view of the metric, including attributes:

Dashboard
You can also check out our custom Claude Code dashboard here which provides specialized visualizations for monitoring your Claude Code usage. The dashboard includes pre-built charts specifically tailored for LLM usage, along with import instructions to get started quickly.

Environment Variable Reference
Every setting below is an environment variable. Set them before launching claude or code ., or deploy them centrally through managed settings. Values verified against the Claude Code monitoring docs.
Required
| Variable | Description | Values | Default |
|---|---|---|---|
CLAUDE_CODE_ENABLE_TELEMETRY | Master switch. Nothing is exported without it | 1 | disabled |
Telemetry is opt-in. If this is unset, every other variable on this page is ignored.
Exporters
At least one exporter must be set, and metrics and events are configured separately. Setting only one means the other signal never appears in SigNoz.
| Variable | Description | Values | Default |
|---|---|---|---|
OTEL_METRICS_EXPORTER | Metrics exporter, comma-separated | otlp, console, prometheus, none | unset |
OTEL_LOGS_EXPORTER | Events exporter, comma-separated | otlp, console, none | unset |
OTEL_TRACES_EXPORTER | Traces exporter, comma-separated (beta) | otlp, console, none | unset |
Endpoint and protocol
| Variable | Description | Values | Default |
|---|---|---|---|
OTEL_EXPORTER_OTLP_ENDPOINT | Destination for all signals | URL | unset |
OTEL_EXPORTER_OTLP_PROTOCOL | Wire protocol for all signals | grpc, http/protobuf, http/json | unset, must be set |
OTEL_EXPORTER_OTLP_HEADERS | Headers sent with every export, used for authentication | key=value pairs | unset |
For SigNoz Cloud, set the protocol to grpc, the endpoint to https://ingest.<region>.signoz.cloud:443 for your region, and the headers to signoz-ingestion-key=<your-ingestion-key>.
Each signal can override the shared values with OTEL_EXPORTER_OTLP_METRICS_*, OTEL_EXPORTER_OTLP_LOGS_* and OTEL_EXPORTER_OTLP_TRACES_* variants of ENDPOINT, PROTOCOL and HEADERS, which is how you send metrics and events to different backends.
Export intervals
| Variable | Description | Values | Default |
|---|---|---|---|
OTEL_METRIC_EXPORT_INTERVAL | Milliseconds between metric exports | integer | 60000 |
OTEL_LOGS_EXPORT_INTERVAL | Milliseconds between event exports | integer | 5000 |
OTEL_TRACES_EXPORT_INTERVAL | Milliseconds between span batch exports (beta) | integer | 5000 |
The 60-second metric default is the most common reason data appears to be missing during setup. Lower it to 10000 while you verify the pipeline.
Content and privacy
Prompt and response content is redacted by default. Each variable below opts a specific category back in, so review them against your data policy before enabling any.
| Variable | Description | Values | Default |
|---|---|---|---|
OTEL_LOG_USER_PROMPTS | Log user prompt text | 1 | redacted |
OTEL_LOG_ASSISTANT_RESPONSES | Log assistant response text | 1, 0, unset falls back to OTEL_LOG_USER_PROMPTS | redacted |
OTEL_LOG_TOOL_DETAILS | Log tool parameters and input arguments | 1 | disabled |
OTEL_LOG_TOOL_CONTENT | Log tool input and output content on spans, requires tracing | 1 | disabled |
OTEL_LOG_RAW_API_BODIES | Emit full Messages API request and response JSON | 1 inline, truncated at 60 KB, or file:<dir> untruncated | disabled |
CLAUDE_CODE_OTEL_CONTENT_MAX_LENGTH | Content attribute limit, in UTF-16 code units | integer | 61440 |
Metric attributes and cardinality
These control which attributes ride along on every metric datapoint. Turning session.id off is the usual fix if metric cardinality becomes a problem.
| Variable | Description | Values | Default |
|---|---|---|---|
OTEL_METRICS_INCLUDE_SESSION_ID | Include session.id | true, false | true |
OTEL_METRICS_INCLUDE_ACCOUNT_UUID | Include user.account_uuid and user.account_id | true, false | true |
OTEL_METRICS_INCLUDE_RESOURCE_ATTRIBUTES | Include keys from OTEL_RESOURCE_ATTRIBUTES | true, false | true |
OTEL_METRICS_INCLUDE_VERSION | Include app.version | true, false | false |
OTEL_METRICS_INCLUDE_ENTRYPOINT | Include app.entrypoint | true, false | false |
OTEL_RESOURCE_ATTRIBUTES | Custom attributes, useful for tagging by team | comma-separated key=value, US-ASCII, no spaces | unset |
OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE | Metric temporality | delta, cumulative | delta |
Tracing (beta)
Spans are separate from the metrics and events covered above and are off by default.
| Variable | Description | Values | Default |
|---|---|---|---|
CLAUDE_CODE_ENHANCED_TELEMETRY_BETA | Required to emit spans at all | 1 | disabled |
CLAUDE_CODE_PROPAGATE_TRACEPARENT | Propagate W3C traceparent to model and MCP requests through a custom proxy | 1 | only sent to the Anthropic API |
TLS
| Variable | Description | Applies to |
|---|---|---|
OTEL_EXPORTER_OTLP_CERTIFICATE | Trust a collector's CA | grpc |
NODE_EXTRA_CA_CERTS | Trust a collector's CA | http/protobuf, http/json |
OTEL_EXPORTER_OTLP_CLIENT_KEY, OTEL_EXPORTER_OTLP_CLIENT_CERTIFICATE | mTLS client credentials | grpc |
CLAUDE_CODE_CLIENT_CERT, CLAUDE_CODE_CLIENT_KEY, CLAUDE_CODE_CLIENT_KEY_PASSPHRASE | mTLS client credentials | http/protobuf, http/json |
Not needed for SigNoz Cloud, which terminates TLS with a public certificate.
Telemetry Data
Claude Code emits the following metrics and events via OpenTelemetry. For the full upstream specification, see the Claude Code monitoring docs.
Standard Attributes
Every metric and event includes these attributes:
| Attribute | Description |
|---|---|
session.id | Unique session identifier |
user.id | Anonymous device/installation identifier |
user.email | User email address (when authenticated via OAuth) |
user.account_uuid | Account UUID (when authenticated) |
user.account_id | Account ID matching Anthropic admin APIs (when authenticated) |
organization.id | Organization UUID (when authenticated) |
terminal.type | Terminal type, e.g. vscode, iTerm.app, cursor, tmux |
app.version | Claude Code version (opt-in via OTEL_METRICS_INCLUDE_VERSION=true) |
Metrics
| Metric | Description | Unit | Key Attributes |
|---|---|---|---|
claude_code.session.count | Sessions started | count | start_type (fresh, resume, continue) |
claude_code.token.usage | Tokens used per API request | tokens | type (input, output, cacheRead, cacheCreation), model, query_source, speed |
claude_code.cost.usage | Estimated cost per API request | USD | model, query_source, speed, agent.name, skill.name, effort |
claude_code.lines_of_code.count | Lines of code added or removed | count | type (added, removed) |
claude_code.commit.count | Git commits created | count | — |
claude_code.pull_request.count | Pull requests or merge requests created | count | — |
claude_code.code_edit_tool.decision | Edit/Write/NotebookEdit permission decisions | count | tool_name, decision (accept/reject), source, language |
claude_code.active_time.total | Active usage time | seconds | type (user for keyboard input, cli for tool/AI response time) |
Events
Claude Code emits these events via the OpenTelemetry logs/events protocol (when OTEL_LOGS_EXPORTER is configured):
| Event | Emitted When | Key Attributes |
|---|---|---|
claude_code.user_prompt | User submits a prompt | prompt_length, command_name, command_source, prompt (redacted by default — enable with OTEL_LOG_USER_PROMPTS=1) |
claude_code.api_request | API request to Claude completes | model, cost_usd, duration_ms, input_tokens, output_tokens, cache_read_tokens, cache_creation_tokens, request_id, speed, query_source |
claude_code.api_error | API request fails after all retries | model, error, status_code, duration_ms, attempt, speed, query_source |
claude_code.api_retries_exhausted | All retry attempts are exhausted | model, error, total_attempts, total_retry_duration_ms, status_code |
claude_code.tool_result | Tool execution completes | tool_name, success, duration_ms, decision_type, decision_source, error_type, tool_input_size_bytes, tool_result_size_bytes |
claude_code.tool_decision | Tool permission is accepted or rejected | tool_name, decision (accept/reject), source (config, hook, user_permanent, user_temporary, user_abort, user_reject) |
claude_code.permission_mode_changed | Permission mode switches | from_mode, to_mode, trigger (shift_tab, exit_plan_mode, auto_gate_denied, auto_opt_in) |
claude_code.mcp_server_connection | MCP server connects, fails, or disconnects | status (connected, failed, disconnected), transport_type, server_scope, duration_ms, error_code |
claude_code.auth | /login or /logout completes | action (login/logout), success, auth_method, error_category |
claude_code.compaction | Conversation compaction completes | trigger (auto/manual), success, pre_tokens, post_tokens, duration_ms |
claude_code.internal_error | Unexpected internal error is caught | error_name, error_code |
claude_code.plugin_installed | Plugin finishes installing | plugin.name, marketplace.name, install.trigger |
claude_code.plugin_loaded | Plugin is active at session start | plugin.name, plugin.scope, plugin.version, enabled_via |
claude_code.skill_activated | Skill is invoked by Claude or as a / command | skill.name, invocation_trigger, skill.source |
claude_code.hook_execution_complete | All hooks for a hook event finish | hook_event, hook_name, num_hooks, num_success, num_blocking, total_duration_ms |
claude_code.feedback_survey | Session quality survey is shown or answered | event_type, survey_type, response |
Troubleshooting
If you don't see your telemetry data in SigNoz:
- Check
CLAUDE_CODE_ENABLE_TELEMETRY- This must be set to1. Telemetry is opt-in and nothing is exported without it - Verify your region and ingestion key - An incorrect
<region>or<your-ingestion-key>will silently drop all data. Double-check against your SigNoz Cloud settings - Check both exporters are set -
OTEL_METRICS_EXPORTERcontrols metrics andOTEL_LOGS_EXPORTERcontrols events. If only one is set, the other signal will not appear - Try a console exporter - Set
OTEL_METRICS_EXPORTER=consoleandOTEL_LOGS_EXPORTER=consoleto confirm Claude Code is generating telemetry locally before sending to SigNoz - Wait for the export interval - The default metrics export interval is 60 seconds. During setup, set
OTEL_METRIC_EXPORT_INTERVAL=10000to flush every 10 seconds instead - Confirm env vars are set before launch - Environment variables must be set before launching
claudeorcode .. Variables exported after launch have no effect
Every variable named above, along with its accepted values and default, is listed in the Environment Variable Reference.
FAQs
Does Claude Code have built-in monitoring?
A. Yes. Claude Code has native OpenTelemetry support that you opt into by setting CLAUDE_CODE_ENABLE_TELEMETRY=1. Once enabled, it emits metrics (token usage, costs, session counts, lines of code, commits) and structured log events (API requests, tool executions, permission decisions) via the standard OTLP protocol to any compatible backend including SigNoz.
What should OTEL_EXPORTER_OTLP_ENDPOINT be for Claude Code?
A. For SigNoz Cloud, set it to https://ingest.<region>.signoz.cloud:443, where <region> matches your SigNoz Cloud region. Pair it with OTEL_EXPORTER_OTLP_PROTOCOL=grpc and OTEL_EXPORTER_OTLP_HEADERS="signoz-ingestion-key=<your-ingestion-key>". For a self-hosted collector it is usually http://localhost:4317 for gRPC or http://localhost:4318 for HTTP. The variable applies to every signal at once; use OTEL_EXPORTER_OTLP_METRICS_ENDPOINT and OTEL_EXPORTER_OTLP_LOGS_ENDPOINT to split them. See the Environment Variable Reference.
How do I track Claude Code token usage?
A. Claude Code emits a claude_code.token.usage metric after every API request, broken down by type (input, output, cacheRead, cacheCreation), model, and query_source. In SigNoz, filter this metric by user or model to see exactly where tokens are going. See the Telemetry Data section for the full attribute list.
Can I monitor Claude Code costs with OpenTelemetry?
A. Yes. The claude_code.cost.usage metric tracks estimated USD cost per API request and includes attributes for model, agent.name, skill.name, and query_source, so you can break down spend by team, model, or workflow. Note that these are approximations — for billing data, refer to your Anthropic Console or cloud provider.
How do I monitor Claude Code across an entire team?
A. Use the Administrator Configuration section to deploy a managed settings file (managed-settings.json) via MDM or your device management solution. This sets CLAUDE_CODE_ENABLE_TELEMETRY=1 and the SigNoz endpoint centrally for all users, without requiring each developer to configure env vars individually.
What is the difference between Claude Code metrics and events?
A. Metrics (like claude_code.token.usage and claude_code.cost.usage) are numeric time-series data, ideal for dashboards, aggregations, and alerts. Events (like claude_code.api_request and claude_code.tool_result) are structured log records emitted per action, ideal for audit trails, debugging, and tracing individual sessions. Both are exported via OpenTelemetry but require separate exporter configuration (OTEL_METRICS_EXPORTER vs OTEL_LOGS_EXPORTER).
Related Articles
A hands-on comparison of Claude Sonnet 4.6, Opus 4.7, and Opus 4.8, instrumenting Claude Code with OpenTelemetry and SigNoz to measure accuracy, cost per solved task, tokens, cache, and error rate on Terminal-Bench.
A practical walkthrough of how to connect Claude Code's monitoring hooks with OpenTelemetry and visualize usage, costs, and performance in SigNoz dashboards.
Learn how to track output-per-token ratios across commits, PRs, and lines of code to detect whether Claude Code's efficiency is degrading over time.
Related integrations
Instrument the other AI agents and assistants you run, using the same OpenTelemetry pipeline:
- Monitor OpenAI Codex with OpenTelemetry - track Codex CLI sessions, token spend, and command-level traces
- OpenCode observability with OpenTelemetry - trace OpenCode sessions, tool calls, and per-message cost
- OpenClaw observability with OpenTelemetry - trace gateway sessions, tool calls, and model usage across your messaging channels
- Monitor the Claude Agent SDK with OpenTelemetry - trace agent loops, tool use, and the model calls behind them
- Instrument LLM apps with OpenLIT - a one-line OpenTelemetry SDK covering GenAI, vector DB, and GPU telemetry
Browse all LLM observability integrations to instrument the rest of your stack.