All skills
Skillintermediate

Monitoring

> ## Documentation Index > Fetch the complete documentation index at: https://code.claude.com/docs/llms.txt > Use this file to discover all available pages before exploring further.

Claude Code Knowledge Pack7/10/2026

Overview

Documentation Index

Fetch the complete documentation index at: https://code.claude.com/docs/llms.txt Use this file to discover all available pages before exploring further.

Monitoring

Learn how to enable and configure OpenTelemetry for Claude Code.

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 the traces protocol. Configure your metrics, logs, and traces backends to match your monitoring requirements.

Quick start

Configure OpenTelemetry using environment variables:

# 1. Enable telemetry

# 2. Choose exporters (both are optional - configure only what you need)

# 3. Configure OTLP endpoint (for OTLP exporter)

# 4. Set authentication (if required)

# 5. For debugging: reduce export intervals

# 6. Run Claude Code
claude

The default export intervals are 60 seconds for metrics and 5 seconds for logs. During setup, you may want to use shorter intervals for debugging purposes. Remember to reset these for production use.

For full configuration options, see the OpenTelemetry specification.

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.

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"
  }
}

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.

Configuration details

Common configuration variables

Environment VariableDescriptionExample Values
CLAUDE_CODE_ENABLE_TELEMETRYEnables telemetry collection (required)1
OTEL_METRICS_EXPORTERMetrics exporter types, comma-separated. Use none to disableconsole, otlp, prometheus, none
OTEL_LOGS_EXPORTERLogs/events exporter types, comma-separated. Use none to disableconsole, otlp, none
OTEL_EXPORTER_OTLP_PROTOCOLProtocol for OTLP exporter, applies to all signalsgrpc, http/json, http/protobuf
OTEL_EXPORTER_OTLP_ENDPOINTOTLP collector endpoint for all signalshttp://localhost:4317
OTEL_EXPORTER_OTLP_METRICS_PROTOCOLProtocol for metrics, overrides general settinggrpc, http/json, http/protobuf
OTEL_EXPORTER_OTLP_METRICS_ENDPOINTOTLP metrics endpoint, overrides general settinghttp://localhost:4318/v1/metrics
OTEL_EXPORTER_OTLP_LOGS_PROTOCOLProtocol for logs, overrides general settinggrpc, http/json, http/protobuf
OTEL_EXPORTER_OTLP_LOGS_ENDPOINTOTLP logs endpoint, overrides general settinghttp://localhost:4318/v1/logs
OTEL_EXPORTER_OTLP_HEADERSAuthentication headers for OTLPAuthorization=Bearer token
OTEL_EXPORTER_OTLP_METRICS_CLIENT_KEYClient key for mTLS authenticationPath to client key file
OTEL_EXPORTER_OTLP_METRICS_CLIENT_CERTIFICATEClient certificate for mTLS authenticationPath to client cert file
OTEL_METRIC_EXPORT_INTERVALExport interval in milliseconds (default: 60000)5000, 60000
OTEL_LOGS_EXPORT_INTERVALLogs export interval in milliseconds (default: 5000)1000, 10000
OTEL_LOG_USER_PROMPTSEnable logging of user prompt content (default: disabled)1 to enable
OTEL_LOG_TOOL_DETAILSEnable logging of tool parameters and input arguments in tool events and trace span attributes: Bash commands, MCP server and tool names, skill names, and tool input. Also enables custom, plugin, and MCP command names on user_prompt events (default: disabled)1 to enable
OTEL_LOG_TOOL_CONTENTEnable logging of tool input and output content in span events (default: disabled). Requires tracing. Content is truncated at 60 KB1 to enable
OTEL_LOG_RAW_API_BODIESEmit the full Anthropic Messages API request and response JSON as api_request_body / api_response_body log events (default: disabled). Bodies include the entire conversation history. Enabling this implies consent to everything OTEL_LOG_USER_PROMPTS, OTEL_LOG_TOOL_DETAILS, and OTEL_LOG_TOOL_CONTENT would reveal1 for inline bodies truncated at 60 KB, or file:<dir> for untruncated bodies on disk with a body_ref pointer in the event
OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCEMetrics temporality preference (default: delta). Set to cumulative if your backend expects cumulative temporalitydelta, cumulative
CLAUDE_CODE_OTEL_HEADERS_HELPER_DEBOUNCE_MSInterval for refreshing dynamic headers (default: 1740000ms / 29 minutes)900000

Metrics cardinality control

The following environment variables control which attributes are included in metrics to manage cardinality:

Environment VariableDescriptionDefault ValueExample to Disable
OTEL_METRICS_INCLUDE_SESSION_IDInclude session.id attribute in metricstruefalse
OTEL_METRICS_INCLUDE_VERSIONInclude app.version attribute in metricsfalsetrue
`OTEL_METRICS_INCLUDE_ACCO