Text of code.claude.com › docs › en › monitoring-usage as Styx crawled it on Nov 19, 2026. The page may have changed since. Only its words are kept, without pictures or layout, and only the first part of a long page.

Open the live page

Monitoring - Claude Code Docs

Documentation Index Fetch the complete documentation index at: /docs/llms.txt Use this file to discover all available pages before exploring further. Skip to main content Assistant Responses are generated using AI and may contain mistakes. Track Claude Code usage, costs, and tool activity across your organization by exporting telemetry data through OpenTelemetry (OTel). Claude Code exports metrics as time series data via the standard metrics protocol, events via the logs/events protocol, and optionally distributed traces via OpenTelemetry .

For the Claude API or Managed Agents, see OpenTelemetry for the Claude API . Quick start Configure OpenTelemetry using environment variables: # 1. Enable telemetry export CLAUDE_CODE_ENABLE_TELEMETRY = 1 # 2. Choose exporters (both are optional - configure only what you need) export OTEL_METRICS_EXPORTER = otlp # Options: otlp, prometheus, console, none export OTEL_LOGS_EXPORTER = otlp # Options: otlp, console, none # 3.

Configure OTLP endpoint (for OTLP exporter) export OTEL_EXPORTER_OTLP_PROTOCOL = grpc export OTEL_EXPORTER_OTLP_ENDPOINT = http :// localhost : 4317 # 4. Set authentication (if required) export OTEL_EXPORTER_OTLP_HEADERS = "Authorization=Bearer your-token" # 5. For debugging: reduce export intervals, and reset them for production use export OTEL_METRIC_EXPORT_INTERVAL = 10000 # 10 seconds (default: 60000ms) export OTEL_LOGS_EXPORT_INTERVAL = 5000 # 5 seconds (default: 5000ms) # 6.

Run Claude Code claude To verify a setup that exports metrics, check your backend for the claude_code.session.count metric, which Claude Code emits when a session starts. To verify a logs-only setup, submit a prompt and check for the claude_code.user_prompt event. If nothing arrives, start Claude Code with claude --debug-file <path> and check the log it writes to that path. Claude Code reports failures from the exporters you configure as [3P telemetry] errors, where 3P means third-party.

Lines prefixed [Anthropic telemetry] describe Anthropic’s separate operational telemetry and don’t indicate a problem with your setup. For full configuration options, see the OpenTelemetry specification . Administrator configuration Administrators can configure OpenTelemetry settings for all users through the managed settings file . See the settings precedence for more information about how settings are applied. 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.example.com:4317" , "OTEL_EXPORTER_OTLP_HEADERS" : "Authorization=Bearer example-token" } } In the Claude Desktop app, Code tab sessions read these managed settings from the sources that reach each kind of Desktop session .

The OpenTelemetry form for Cowork under Monitoring in the admin console’s Data and privacy settings applies to Cowork sessions only, so neither the terminal CLI nor the Code tab exports to a collector you set there. Claude Code ignores the OpenTelemetry exporter variables in a repository’s .claude/settings.json and .claude/settings.local.json , so a repository can’t use them to turn telemetry on, choose where it goes, or capture content.

Set them in managed settings, or have each developer set them in their shell or ~/.claude/settings.json . A repository can still turn a signal off by setting its exporter selector, such as OTEL_LOGS_EXPORTER , to none , unless managed settings, a --settings file, or the environment you start Claude Code from sets that variable. Claude Code doesn’t pass OTEL_* environment variables to the subprocesses it spawns, including the Bash tool, hooks, MCP servers, and language servers.

An OpenTelemetry-instrumented application that you run through the Bash tool doesn’t inherit Claude Code’s exporter endpoint or headers, so set those variables directly in the command if that application needs to export its own telemetry. How managed settings lock the OTLP destination When you set an OTEL_EXPORTER_OTLP_* variable in managed settings, Claude Code removes conflicting developer-set variables at startup and logs a warning in the debug log.

What it removes depends on which variable you set: Endpoints : when you set OTEL_EXPORTER_OTLP_ENDPOINT , Claude Code removes every developer-set per-signal endpoint. Developers can’t point one signal at a different collector, so you don’t need to also set the per-signal endpoint variables in managed settings. Protocols : when you set OTEL_EXPORTER_OTLP_PROTOCOL , Claude Code removes every developer-set per-signal protocol.

Credentials : when you set OTEL_EXPORTER_OTLP_HEADERS , OTEL_EXPORTER_OTLP_CLIENT_KEY , or OTEL_EXPORTER_OTLP_CLIENT_CERTIFICATE , Claude Code removes the developer-set per-signal versions of that variable, plus every developer-set endpoint variable, generic or per-signal, since those credentials would otherwise reach a collector the managed settings didn’t choose. Exporter selectors : OTEL_METRICS_EXPORTER , OTEL_LOGS_EXPORTER , and the beta OTEL_TRACES_EXPORTER follow normal per-key precedence.

A developer’s setting can still disable a signal or switch it to the console exporter, so set the selectors in managed settings too if you need them locked. Across admin sources , OTEL_LOGS_EXPORTER follows the telemetry unit while the other two selectors merge per key. Requires Claude Code v2.1.223 or later. Beta tracing endpoints : with detailed beta tracing active, Claude Code exports logs and traces to BETA_TRACING_ENDPOINT instead of through the logs and traces exporters.

Claude Code therefore removes a developer-set BETA_TRACING_ENDPOINT whenever any of these managed settings decides either signal’s destination: A generic or logs/traces endpoint or credential An otelHeadersHelper A logs or traces exporter selector set to none , console , or empty, values that keep the signal off a collector CLAUDE_CODE_ENABLE_TELEMETRY turned off A metrics-only endpoint or credential doesn’t remove it.

Before v2.1.251, a developer-set BETA_TRACING_ENDPOINT redirected the logs and traces that detailed beta tracing exports even when managed settings pinned the collector. Claude Code doesn’t remove per-signal variables that you set in managed settings itself, so you can route one signal to a different collector by setting its variable there, as the SIEM example does. If you set a per-signal credential there, Claude Code removes the developer-set endpoint for that signal.

This removal behavior changes where telemetry is delivered, not what Claude Code collects. Before v2.1.217, every variable followed per-key settings precedence independently, so a signal-specific endpoint set in user settings or the shell redirected that signal away from the managed collector. When the desktop app or a self-hosted environment runner launches Claude Code and names an OTLP endpoint in the environment it provides, Claude Code pins the destination the same way: the launcher’s telemetry variables remove developer-set variables exactly as managed settings do.

Claude Code doesn’t remove variables that the launcher itself set. Requires Claude Code v2.1.251 or later. Configuration details Common configuration variables These variables configure exporters, endpoints, and export behavior for all deployments. If you set a per-signal endpoint or protocol variable, such as OTEL_EXPORTER_OTLP_METRICS_ENDPOINT , Claude Code uses it instead of the generic variable for that signal. If you set a per-signal headers variable, such as OTEL_EXPORTER_OTLP_METRICS_HEADERS , Claude Code merges it with the generic OTEL_EXPORTER_OTLP_HEADERS for that signal.

On machines with managed settings, see How managed settings lock the OTLP destination for what Claude Code removes. Environment Variable Description Example Values CLAUDE_CODE_ENABLE_TELEMETRY Enables telemetry collection (required) 1 OTEL_METRICS_EXPORTER Metrics expo

The rest of this page is on the live site.