Learning resourcesReviewed · Anthropic

Claude Code Monitoring: OpenTelemetry guide

Claude Code Monitoring is a guide for developers and administrators tracking the coding assistant, but organization-wide reporting needs a separately configured monitoring backend. It explains OpenTelemetry metrics, event logs and optional beta traces, with controls for cost attribution, exporter routing and sensitive content.

Researched 25 Nov 2026

In short.

Claude Code Monitoring is a guide for developers and administrators who need usage and audit data, but they must configure the backend that stores, queries and alerts on it. It documents metrics, structured events, beta tracing, identity attribution and managed exporter controls. Cost figures are estimates, default events can include user identities, and optional content logging can expose conversation history or tool data. Export delivery, performance and backend compatibility remain untested.

Researched and written by an AI model and checked by a second AI model. How it works

Coverage is limited to the complete selected documentation page at [https://code.claude.com/docs/en/monitoring-usage.md]. It includes the page's beta warnings, privacy notices, historical event definitions and version-dependent configuration behavior. Linked pages, repositories, specifications and billing material are excluded. No configuration was executed; export delivery, backend compatibility, performance and security enforcement remain untested. Redistribution rights are not established.

The overview

Identity

The resource is the Monitoring page in Anthropic's Claude Code documentation at [https://code.claude.com/docs/en/monitoring-usage.md]. It is a configuration guide and signal reference for exporting Claude Code activity through OpenTelemetry, a standard for sending operational data to monitoring systems.

Its scope includes terminal sessions, relevant Claude Desktop Code tab sessions, cloud sessions and Claude Tag. The page directs Claude API and Managed Agents users to separate documentation.

Assessment

The guide is useful for organizations that already use Claude Code and want to understand adoption, estimated spend, tool activity or permission decisions. Its strongest material covers configuration precedence, privacy controls, event correlation and troubleshooting missing exports.

The reader must provide the monitoring destination and implement dashboards, queries, anomaly detection and alerts. The page supplies detailed interfaces and configuration examples, but it provides no measured deployment overhead, delivery guarantees or independent validation of the resulting reports.

Users

Organization administrators and platform engineers can use it to configure telemetry across developers, teams and deployment surfaces. Security teams can use the event definitions to investigate tool permissions, MCP connections, authentication and plugin activity. Teams tracking expenditure can attribute estimated usage to models, agents, skills and plugins.

Individual developers can begin with console exports to inspect telemetry locally. Beginners need some familiarity with environment variables and monitoring endpoints; experienced developers get details on mutual TLS authentication, dynamic credentials, managed settings and distributed trace context.

Capabilities

Documented metrics include session starts, changed lines, commits, pull requests, estimated USD cost, tokens, code-edit permission decisions and active time. Token and cost data support attribution by model and request source, with additional agent, skill, plugin and MCP attributes where applicable.

Structured events cover prompts, assistant responses, API outcomes, tool results and decisions, authentication, MCP connections, plugin and hook inventory, compaction, subagent completion, retention cleanup and managed settings resolution. Optional traces connect a prompt to model requests, tool calls and nested subagent activity.

Metrics can use OTLP, Prometheus or console exporters. Logs and traces support OTLP or console export. Custom resource attributes allow team or cost-center grouping, while separate endpoints can route metrics and logs to different destinations.

Using it

Requirements

Telemetry requires CLAUDE_CODE_ENABLE_TELEMETRY=1 and an exporter for each desired signal. Remote OTLP export also needs a reachable receiver, matching protocol and any required authentication. Prometheus requires a system that scrapes the exposed metrics endpoint.

A universal minimum version for basic telemetry is not stated. Individual features have minimum versions: the documented automatic HTTP/protobuf default requires v2.1.323 or later, and automatic host attributes require v2.1.326 or later. Tracing additionally needs CLAUDE_CODE_ENHANCED_TELEMETRY_BETA=1 and a traces exporter.

For organization deployment, use applicable managed settings or developer-level configuration. Repository settings cannot enable or redirect exporters or turn on content capture through the protected exporter variables. Cloud sessions need configuration that reaches their cloud environment; Claude Tag does not receive server-managed settings, and Cowork has separate configuration.

Mechanism

Metrics are numeric time series, events are structured log records, and traces are linked spans showing the work behind an interaction. The prompt.id attribute groups events triggered by one prompt; tool_use_id identifies a tool invocation, and request_id can connect events to a model request.

Signal-specific endpoints and protocols normally override generic OTLP settings, while signal-specific headers merge with generic headers. Managed destination settings remove conflicting developer settings according to documented, version-dependent rules. Exporter selectors must also be managed if administrators need to prevent a developer from disabling a signal or switching it to console output.

Metrics default to delta temporality, which reports changes between exports; cumulative temporality is configurable for backends that require it. Claude Code does not pass OTEL_* variables to its subprocesses. With tracing enabled, supported subprocesses can receive TRACEPARENT context, although propagation through a custom API proxy requires an additional opt-in.

Setup

For the documented local gRPC setup, first provide a running collector. Before starting claude, set CLAUDE_CODE_ENABLE_TELEMETRY=1, OTEL_METRICS_EXPORTER=otlp, OTEL_LOGS_EXPORTER=otlp and OTEL_EXPORTER_OTLP_PROTOCOL=grpc. Set OTEL_EXPORTER_OTLP_ENDPOINT to [http://localhost:4317], or to your collector's actual address, and supply OTEL_EXPORTER_OTLP_HEADERS if authentication is required.

The guide recommends checking for claude_code.session.count after a session starts. For logs-only export, submit a prompt and look for claude_code.user_prompt. If data is missing, use claude --debug-file with a chosen file path and inspect [3P telemetry] errors; [Anthropic telemetry] messages concern a separate telemetry service.

Documented default export intervals are 60 seconds for metrics and 5 seconds for logs. Administrators can put the environment settings in managed configuration. Dynamic authentication helpers work with HTTP/protobuf and HTTP/JSON, but not gRPC; helper failures stop exports until the helper works again.

Example

For a security team with an existing SIEM receiver, the page gives an events-only managed-settings example. It enables telemetry, selects the OTLP logs exporter, uses HTTP/protobuf, points OTEL_EXPORTER_OTLP_LOGS_ENDPOINT to [https://siem.example.com:4318/v1/logs] and supplies an authentication header. The address is a placeholder for the team's receiver.

That example also sets OTEL_LOG_TOOL_DETAILS=1 to expose Bash commands, MCP server and tool names, and tool arguments. Accepted calls can produce tool_result events, while rejected calls are recorded through tool_decision. Correlating tool_use_id connects those records. This configuration can export sensitive arguments, and some tool-input fields are truncated, so it should not be treated as a complete transcript.

Assessment & evidence

Limitations

Content redaction does not make default telemetry anonymous. Events can include email and account identifiers when available. Direct API-key and third-party-provider sessions lack Claude account identity, so per-person attribution needs additional configuration; Claude Tag uses an organizational shared identity.

OTEL_LOG_USER_PROMPTS also controls assistant-response event text when OTEL_LOG_ASSISTANT_RESPONSES is unset. Setting the latter to 0 keeps those event responses redacted, but detailed beta tracing has a separate model-output attribute controlled by prompt logging. Raw API body logging can expose conversation history, system prompts and tool results despite the narrower content flags.

Tracing is beta. Detailed beta tracing has unstable content attributes, changes where logs and traces are delivered, and is documented for debugging rather than production use. Current documented versions no longer emit safety_event: v2.1.312 and later cannot enable it. Tool decisions remain available, but they do not always identify the precise rule or check responsible.

Event sequence numbers belong to processes and can repeat or decrease within a resumed session. Transcript joins are version-specific, content fields have truncation limits, and missing retention events alone do not prove a cleanup failure. Runtime performance, delivery reliability and enforcement behavior are not assessed.

Reasoning

Choose signals according to the question. Metrics support trends and aggregate usage; events provide individual API and tool outcomes; traces explain the timing and nesting of work behind a prompt. Exporting every signal and enabling every content flag is not necessary for basic adoption or estimated-spend reporting.

The guide's definitions require care when interpreting results. Sessions are not people, a subagent_completed event's total_tokens covers only its final request, and input_tokens excludes cache reads and writes. For the OpenTelemetry GenAI input-token total, add input_tokens, cache_read_tokens and cache_creation_tokens.

Changed lines, commits and pull requests measure activity. They do not by themselves establish code quality, productivity gains or return on investment. The page provides no outcome study demonstrating those relationships.

Alternatives

Within the guide, console export is an option for local inspection, Prometheus supports metrics scraping, and OTLP supports delivery to compatible monitoring or security systems. Metrics-only export can support usage trends; logs-only export can support event auditing. The page does not benchmark these approaches or compare named commercial backends.

The page links to the Claude Code ROI Measurement Guide at [https://github.com/anthropics/claude-code-monitoring-guide] and an Amazon Bedrock monitoring guide at [https://github.com/aws-solutions-library-samples/guidance-for-claude-code-with-amazon-bedrock/blob/main/assets/docs/MONITORING.md]. Their contents, compatibility and licences are not assessed here.

Evidence

The evidence is the complete supplied Monitoring documentation page at [https://code.claude.com/docs/en/monitoring-usage.md]. It contains configuration examples, environment-variable definitions, metric and event schemas, version qualifications, troubleshooting guidance and privacy notices.

These are first-party descriptions of intended behavior. The supplied evidence contains no independent execution results, backend compatibility measurements or performance benchmarks. Linked specifications, billing documentation, repositories and related product pages have not been assessed.

Access & freshness

Costs

The page does not establish Claude Code subscription prices, API rates, monitoring service charges or total operating cost. Those costs remain unknown. The claude_code.cost.usage metric and API cost fields are estimates; the documentation directs readers elsewhere for official billing data.

Backend storage costs depend partly on telemetry volume and cardinality, meaning how many distinct combinations of attribute values create separate metric series. Session identifiers, custom labels, frequent exports and content capture can increase the amount of data handled. Detailed beta tracing is explicitly described as high volume, but no measured overhead or cost estimate is provided.

Rights

The selected page states no redistribution licence for its documentation or examples and does not establish licence terms for Claude Code. Permission to redistribute these materials is therefore unknown from this evidence. Licences for linked repositories are also not established by the page.

Freshness

The supplied capture is dated 25 November 2026. The page's publication date, last-edit date and the latest available Claude Code release are not established.

Version qualifications materially affect deployment. The page distinguishes earlier destination-override behavior, beta endpoint fixes in v2.1.251, the HTTP/protobuf default from v2.1.323, host attributes from v2.1.326 and tool-sent response events from v2.1.332. Monitoring rules should match the installed version, especially where older event types have been removed.

Actions

Start with a concrete question, such as adoption by team, estimated cost by model or rejected MCP calls. Select the required signals, confirm the installed version supports their fields, and configure a reachable receiver with the correct protocol and authentication.

Before enabling content logging, inspect which identity and content attributes the backend will receive. Keep unnecessary content flags disabled, account for the assistant-response fallback, and configure filtering for sensitive fields. If prompt text is collected, filtering must account for both prompt and prompt_text as well as any enabled trace content.

Confirm arrival using the documented session metric or prompt event, then build the relevant queries and alerts. For managed deployments, configure exporter selectors as well as destinations. For cloud deployments, check network access and configuration coverage. Use official billing data to reconcile spending and separate outcome measures to evaluate productivity.

Evidence for this report

selected-page.txtselected · checked 2026-11-25