{"slug": "claude-code-monitoring-observability-with-opentelemetry", "title": "Claude Code Monitoring & Observability with OpenTelemetry", "summary": "SigNoz has released a guide for monitoring Anthropic's Claude Code AI assistant using OpenTelemetry, enabling engineering teams to export logs and metrics on token usage, costs, session activity, and tool decisions to SigNoz dashboards. The integration requires a SigNoz account and Claude Code installation, with setup options for both VSCode and terminal environments using environment variables or bash scripts. Administrators can centrally configure OpenTelemetry settings across their organization through managed settings files for unified visibility into AI usage patterns.", "body_md": "Overview\n\nClaude 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:\n\n**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\n\nOnce set up, all of this flows into SigNoz dashboards where you can correlate logs and metrics, set alerts, and analyze trends over time.\n\nPrerequisites\n\n- SigNoz setup (choose one):\n[SigNoz Cloud account](https://signoz.io/teams/)with an active ingestion key- Self-hosted SigNoz instance\n\n- Internet access to send telemetry data to SigNoz Cloud\n[Claude Code](https://www.anthropic.com/claude-code)installed and running on your system\n\nMonitoring Claude Code\n\nCheck out detailed instructions on how to set up OpenTelemetry instrumentation for your Claude Code usage over [here](https://docs.anthropic.com/en/docs/claude-code/monitoring-usage).\n\nOption 1 (VSCode)\n\n**Step 1:** Launch VSCode with telemetry enabled\n\n```\nCLAUDE_CODE_ENABLE_TELEMETRY=1 \\\nOTEL_METRICS_EXPORTER=otlp \\\nOTEL_LOGS_EXPORTER=otlp \\\nOTEL_EXPORTER_OTLP_PROTOCOL=grpc \\\nOTEL_EXPORTER_OTLP_ENDPOINT=\"https://ingest.<region>.signoz.cloud:443\" \\\nOTEL_EXPORTER_OTLP_HEADERS=\"signoz-ingestion-key=<your-ingestion-key>\" \\\nOTEL_METRIC_EXPORT_INTERVAL=10000 \\\nOTEL_LOGS_EXPORT_INTERVAL=5000 \\\ncode .\n```\n\n: Your SigNoz Cloud`<region>`\n\n**region**: Your SigNoz`<your-ingestion-key>`\n\n**ingestion key**\n\nUsing self-hosted SigNoz? Most steps are identical. To adapt this guide, update the endpoint and remove the ingestion key header as shown in [Cloud → Self-Hosted](https://signoz.io/docs/ingestion/cloud-vs-self-hosted/#cloud-to-self-hosted).\n\nThis 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.\n\nFor convenience, you can also clone our [bash script](https://github.com/SigNoz/Claude-Code-OpenTelemetry/blob/main/claude_code_otel_vscode.sh), update it with your SigNoz endpoint and ingestion key, and run it directly.\n\nOption 2 (Terminal)\n\n**Step 1:** Launch Claude Code with telemetry enabled\n\n```\nCLAUDE_CODE_ENABLE_TELEMETRY=1 \\\nOTEL_METRICS_EXPORTER=otlp \\\nOTEL_LOGS_EXPORTER=otlp \\\nOTEL_EXPORTER_OTLP_PROTOCOL=grpc \\\nOTEL_EXPORTER_OTLP_ENDPOINT=\"https://ingest.<region>.signoz.cloud:443\" \\\nOTEL_EXPORTER_OTLP_HEADERS=\"signoz-ingestion-key=<your-ingestion-key>\" \\\nOTEL_METRIC_EXPORT_INTERVAL=10000 \\\nOTEL_LOGS_EXPORT_INTERVAL=5000 \\\nclaude\n```\n\n- Set the\nto match your SigNoz Cloud`<region>`\n\n**region** - Replace\nwith your SigNoz`<your-ingestion-key>`\n\n**ingestion key**\n\nUsing self-hosted SigNoz? Most steps are identical. To adapt this guide, update the endpoint and remove the ingestion key header as shown in [Cloud → Self-Hosted](https://signoz.io/docs/ingestion/cloud-vs-self-hosted/#cloud-to-self-hosted).\n\nThis 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.\n\nFor convenience, you can also clone our [bash script](https://github.com/SigNoz/Claude-Code-OpenTelemetry/blob/main/claude_code_otel_terminal.sh), update it with your SigNoz endpoint and ingestion key, and run it directly.\n\nAdministrator Configuration\n\nAdministrators 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](https://docs.anthropic.com/en/docs/claude-code/settings#settings-precedence) for more information about how settings are applied.\n\nThe managed settings file is located at:\n\n- macOS:\n`/Library/Application Support/ClaudeCode/managed-settings.json`\n\n- Linux and WSL:\n`/etc/claude-code/managed-settings.json`\n\n- Windows:\n`C:\\ProgramData\\ClaudeCode\\managed-settings.json`\n\nExample managed settings configuration:\n\n```\n{\n  \"env\": {\n    \"CLAUDE_CODE_ENABLE_TELEMETRY\": \"1\",\n    \"OTEL_METRICS_EXPORTER\": \"otlp\",\n    \"OTEL_LOGS_EXPORTER\": \"otlp\",\n    \"OTEL_EXPORTER_OTLP_PROTOCOL\": \"grpc\",\n    \"OTEL_EXPORTER_OTLP_ENDPOINT\": \"http://collector.company.com:4317\",\n    \"OTEL_EXPORTER_OTLP_HEADERS\": \"Authorization=Bearer company-token\"\n  }\n}\n```\n\nManaged 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.\n\nExample Configurations\n\n```\n# Console debugging (1-second intervals)\nexport CLAUDE_CODE_ENABLE_TELEMETRY=1\nexport OTEL_METRICS_EXPORTER=console\nexport OTEL_METRIC_EXPORT_INTERVAL=1000\n\n# OTLP/gRPC\nexport CLAUDE_CODE_ENABLE_TELEMETRY=1\nexport OTEL_METRICS_EXPORTER=otlp\nexport OTEL_EXPORTER_OTLP_PROTOCOL=grpc\nexport OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317\n\n# Prometheus\nexport CLAUDE_CODE_ENABLE_TELEMETRY=1\nexport OTEL_METRICS_EXPORTER=prometheus\n\n# Multiple exporters\nexport CLAUDE_CODE_ENABLE_TELEMETRY=1\nexport OTEL_METRICS_EXPORTER=console,otlp\nexport OTEL_EXPORTER_OTLP_PROTOCOL=http/json\n\n# Different endpoints/backends for metrics and logs\nexport CLAUDE_CODE_ENABLE_TELEMETRY=1\nexport OTEL_METRICS_EXPORTER=otlp\nexport OTEL_LOGS_EXPORTER=otlp\nexport OTEL_EXPORTER_OTLP_METRICS_PROTOCOL=http/protobuf\nexport OTEL_EXPORTER_OTLP_METRICS_ENDPOINT=http://metrics.company.com:4318\nexport OTEL_EXPORTER_OTLP_LOGS_PROTOCOL=grpc\nexport OTEL_EXPORTER_OTLP_LOGS_ENDPOINT=http://logs.company.com:4317\n\n# Metrics only (no events/logs)\nexport CLAUDE_CODE_ENABLE_TELEMETRY=1\nexport OTEL_METRICS_EXPORTER=otlp\nexport OTEL_EXPORTER_OTLP_PROTOCOL=grpc\nexport OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317\n\n# Events/logs only (no metrics)\nexport CLAUDE_CODE_ENABLE_TELEMETRY=1\nexport OTEL_LOGS_EXPORTER=otlp\nexport OTEL_EXPORTER_OTLP_PROTOCOL=grpc\nexport OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317\n```\n\nYour Claude Code activity should now automatically emit logs and metrics.\n\nFinally, you should be able to view logs in Signoz Cloud under the logs tab:\n\nWhen you click on any of these logs in SigNoz, you'll see a detailed view of the log, including attributes:\n\nYou should be able to see Claude Code related metrics in Signoz Cloud under the metrics tab:\n\nWhen you click on any of these metrics in SigNoz, you'll see a detailed view of the metric, including attributes:\n\nDashboard\n\nYou can also check out our custom Claude Code dashboard [here](https://signoz.io/docs/dashboards/dashboard-templates/claude-code-dashboard/) 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.\n\nTelemetry Data\n\nClaude Code emits the following metrics and events via OpenTelemetry. For the full upstream specification, see the [Claude Code monitoring docs](https://docs.anthropic.com/en/docs/claude-code/monitoring-usage).\n\nStandard Attributes\n\nEvery metric and event includes these attributes:\n\n| Attribute | Description |\n|---|---|\n`session.id` | Unique session identifier |\n`user.id` | Anonymous device/installation identifier |\n`user.email` | User email address (when authenticated via OAuth) |\n`user.account_uuid` | Account UUID (when authenticated) |\n`user.account_id` | Account ID matching Anthropic admin APIs (when authenticated) |\n`organization.id` | Organization UUID (when authenticated) |\n`terminal.type` | Terminal type, e.g. `vscode` , `iTerm.app` , `cursor` , `tmux` |\n`app.version` | Claude Code version (opt-in via `OTEL_METRICS_INCLUDE_VERSION=true` ) |\n\nMetrics\n\n| Metric | Description | Unit | Key Attributes |\n|---|---|---|---|\n`claude_code.session.count` | Sessions started | count | `start_type` (`fresh` , `resume` , `continue` ) |\n`claude_code.token.usage` | Tokens used per API request | tokens | `type` (`input` , `output` , `cacheRead` , `cacheCreation` ), `model` , `query_source` , `speed` |\n`claude_code.cost.usage` | Estimated cost per API request | USD | `model` , `query_source` , `speed` , `agent.name` , `skill.name` , `effort` |\n`claude_code.lines_of_code.count` | Lines of code added or removed | count | `type` (`added` , `removed` ) |\n`claude_code.commit.count` | Git commits created | count | — |\n`claude_code.pull_request.count` | Pull requests or merge requests created | count | — |\n`claude_code.code_edit_tool.decision` | Edit/Write/NotebookEdit permission decisions | count | `tool_name` , `decision` (`accept` /`reject` ), `source` , `language` |\n`claude_code.active_time.total` | Active usage time | seconds | `type` (`user` for keyboard input, `cli` for tool/AI response time) |\n\nEvents\n\nClaude Code emits these events via the OpenTelemetry logs/events protocol (when `OTEL_LOGS_EXPORTER`\n\nis configured):\n\n| Event | Emitted When | Key Attributes |\n|---|---|---|\n`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` ) |\n`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` |\n`claude_code.api_error` | API request fails after all retries | `model` , `error` , `status_code` , `duration_ms` , `attempt` , `speed` , `query_source` |\n`claude_code.api_retries_exhausted` | All retry attempts are exhausted | `model` , `error` , `total_attempts` , `total_retry_duration_ms` , `status_code` |\n`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` |\n`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` ) |\n`claude_code.permission_mode_changed` | Permission mode switches | `from_mode` , `to_mode` , `trigger` (`shift_tab` , `exit_plan_mode` , `auto_gate_denied` , `auto_opt_in` ) |\n`claude_code.mcp_server_connection` | MCP server connects, fails, or disconnects | `status` (`connected` , `failed` , `disconnected` ), `transport_type` , `server_scope` , `duration_ms` , `error_code` |\n`claude_code.auth` | `/login` or `/logout` completes | `action` (`login` /`logout` ), `success` , `auth_method` , `error_category` |\n`claude_code.compaction` | Conversation compaction completes | `trigger` (`auto` /`manual` ), `success` , `pre_tokens` , `post_tokens` , `duration_ms` |\n`claude_code.internal_error` | Unexpected internal error is caught | `error_name` , `error_code` |\n`claude_code.plugin_installed` | Plugin finishes installing | `plugin.name` , `marketplace.name` , `install.trigger` |\n`claude_code.plugin_loaded` | Plugin is active at session start | `plugin.name` , `plugin.scope` , `plugin.version` , `enabled_via` |\n`claude_code.skill_activated` | Skill is invoked by Claude or as a `/` command | `skill.name` , `invocation_trigger` , `skill.source` |\n`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` |\n`claude_code.feedback_survey` | Session quality survey is shown or answered | `event_type` , `survey_type` , `response` |\n\nAll events share a `prompt.id`\n\nattribute, a UUID that links every event produced while processing a single user prompt. Filter by `prompt.id`\n\nin SigNoz to correlate all API requests and tool executions triggered by one prompt.\n\nTroubleshooting\n\nIf you don't see your telemetry data in SigNoz:\n\n**Check**- This must be set to`CLAUDE_CODE_ENABLE_TELEMETRY`\n\n`1`\n\n. Telemetry is opt-in and nothing is exported without it**Verify your region and ingestion key**- An incorrect`<region>`\n\nor`<your-ingestion-key>`\n\nwill silently drop all data. Double-check against your[SigNoz Cloud settings](https://signoz.io/docs/ingestion/signoz-cloud/keys/)**Check both exporters are set**-`OTEL_METRICS_EXPORTER`\n\ncontrols metrics and`OTEL_LOGS_EXPORTER`\n\ncontrols events. If only one is set, the other signal will not appear**Try a console exporter**- Set`OTEL_METRICS_EXPORTER=console`\n\nand`OTEL_LOGS_EXPORTER=console`\n\nto 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=10000`\n\nto flush every 10 seconds instead**Confirm env vars are set before launch**- Environment variables must be set before launching`claude`\n\nor`code .`\n\n. Variables exported after launch have no effect\n\nFAQs\n\nDoes Claude Code have built-in monitoring?\n\nA. Yes. Claude Code has native OpenTelemetry support that you opt into by setting `CLAUDE_CODE_ENABLE_TELEMETRY=1`\n\n. 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.\n\nHow do I track Claude Code token usage?\n\nA. Claude Code emits a `claude_code.token.usage`\n\nmetric after every API request, broken down by `type`\n\n(`input`\n\n, `output`\n\n, `cacheRead`\n\n, `cacheCreation`\n\n), `model`\n\n, and `query_source`\n\n. In SigNoz, filter this metric by user or model to see exactly where tokens are going. See the [Telemetry Data](#telemetry-data) section for the full attribute list.\n\nCan I monitor Claude Code costs with OpenTelemetry?\n\nA. Yes. The `claude_code.cost.usage`\n\nmetric tracks estimated USD cost per API request and includes attributes for `model`\n\n, `agent.name`\n\n, `skill.name`\n\n, and `query_source`\n\n, 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.\n\nHow do I monitor Claude Code across an entire team?\n\nA. Use the Administrator Configuration section to deploy a managed settings file (`managed-settings.json`\n\n) via MDM or your device management solution. This sets `CLAUDE_CODE_ENABLE_TELEMETRY=1`\n\nand the SigNoz endpoint centrally for all users, without requiring each developer to configure env vars individually.\n\nWhat is the difference between Claude Code metrics and events?\n\nA. Metrics (like `claude_code.token.usage`\n\nand `claude_code.cost.usage`\n\n) are numeric time-series data, ideal for dashboards, aggregations, and alerts. Events (like `claude_code.api_request`\n\nand `claude_code.tool_result`\n\n) 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`\n\nvs `OTEL_LOGS_EXPORTER`\n\n).\n\nRelated Articles\n\n[Bringing Observability to Claude Code: OpenTelemetry in Action](https://signoz.io/blog/claude-code-monitoring-with-opentelemetry/)\n\nA practical walkthrough of how to connect Claude Code's monitoring hooks with OpenTelemetry and visualize usage, costs, and performance in SigNoz dashboards.\n\n[Is Claude Code Getting Worse? How to Measure Degradation with OpenTelemetry](https://signoz.io/blog/claude-code-measure-degradation-opentelemetry/)\n\nLearn 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.", "url": "https://wpnews.pro/news/claude-code-monitoring-observability-with-opentelemetry", "canonical_source": "https://signoz.io/docs/claude-code-monitoring", "published_at": "2026-06-09 00:00:00+00:00", "updated_at": "2026-06-11 19:38:17.261274+00:00", "lang": "en", "topics": ["ai-tools", "ai-infrastructure", "mlops", "large-language-models", "ai-agents"], "entities": ["Claude Code", "SigNoz", "OpenTelemetry", "Anthropic"], "alternates": {"html": "https://wpnews.pro/news/claude-code-monitoring-observability-with-opentelemetry", "markdown": "https://wpnews.pro/news/claude-code-monitoring-observability-with-opentelemetry.md", "text": "https://wpnews.pro/news/claude-code-monitoring-observability-with-opentelemetry.txt", "jsonld": "https://wpnews.pro/news/claude-code-monitoring-observability-with-opentelemetry.jsonld"}}