Claude Code

Monitoring and analytics

OpenTelemetry, analytics dashboards, usage/cost events, traceparent, privacy controls, team metrics and Passion8 boundaries.

Code offers configurable local/enterprise OpenTelemetry and Anthropic organizational analytics. They serve different purposes.

CapabilityBest fit
OpenTelemetryExport usage, costs, tools and traces to enterprise systems
AnalyticsOrganizational adoption, activity, accepted lines and spend
/usage, /cost, status lineIndividual session and plan visibility
Passion8 consoleGateway balance, requests and actual charges

Local OTel works through Passion8, but Anthropic analytics may not reflect third-party billing. Passion8 is authoritative for its balance and charges.

#OpenTelemetry quickstart

export CLAUDE_CODE_ENABLE_TELEMETRY=1
export OTEL_METRICS_EXPORTER=otlp
export OTEL_LOGS_EXPORTER=otlp
export OTEL_EXPORTER_OTLP_PROTOCOL=grpc
export OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317
export OTEL_EXPORTER_OTLP_HEADERS="Authorization=Bearer your-token"

claude

Shorten export intervals for diagnostics:

export OTEL_METRIC_EXPORT_INTERVAL=10000
export OTEL_LOGS_EXPORT_INTERVAL=5000

Avoid overly short production intervals that burden clients and collectors.

#Administrator delivery

Enable through managed settings:

managed settings
{
  "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 environment settings have high priority. OTEL variables are not automatically forwarded to Bash, hooks, MCP or language servers; configure those separately.

#Common environment variables

VariablePurpose
CLAUDE_CODE_ENABLE_TELEMETRYEnable telemetry
OTEL_METRICS_EXPORTERotlp、prometheus、console、none
OTEL_LOGS_EXPORTERotlp、console、none
OTEL_EXPORTER_OTLP_PROTOCOLgrpc、http/json、http/protobuf
OTEL_EXPORTER_OTLP_ENDPOINTCollector address
OTEL_EXPORTER_OTLP_HEADERSStatic auth headers
OTEL_METRIC_EXPORT_INTERVALMetric interval
OTEL_LOGS_EXPORT_INTERVALLog interval
OTEL_LOG_USER_PROMPTSRaw prompts
OTEL_LOG_ASSISTANT_RESPONSESAssistant text
OTEL_LOG_TOOL_DETAILSArguments, commands and MCP names
OTEL_LOG_TOOL_CONTENTTool payloads in traces
OTEL_LOG_RAW_API_BODIESFull request/response bodies; highest sensitivity
CLAUDE_CODE_OTEL_HEADERS_HELPER_DEBOUNCE_MSDynamic-header refresh interval

Keep raw API logging off by default; it can contain complete history, files, tools and secrets. Enable only briefly in isolated diagnostics.

#Metrics cardinality

High-cardinality labels raise storage costs. Available controls:

VariableDefaultPurpose
OTEL_METRICS_INCLUDE_SESSION_IDtrueInclude session identifier
OTEL_METRICS_INCLUDE_VERSIONfalseInclude client version
OTEL_METRICS_INCLUDE_ACCOUNT_UUIDtrueInclude account identifier
OTEL_METRICS_INCLUDE_ENTRYPOINTfalseInclude entry point
OTEL_METRICS_INCLUDE_RESOURCE_ATTRIBUTEStrueResource attributes as point labels

For team dimensions:

export OTEL_RESOURCE_ATTRIBUTES="department=engineering,team.id=platform,cost_center=eng-123"

Avoid spaces and random high-cardinality values here.

#Traces

Tracing requires the additional beta switch:

export CLAUDE_CODE_ENABLE_TELEMETRY=1
export CLAUDE_CODE_ENHANCED_TELEMETRY_BETA=1
export OTEL_TRACES_EXPORTER=otlp

Each prompt creates a claude_code.interaction root span with model, tool and hook children. Subagent spans attach beneath the parent Agent tool span.

claude_code.interaction
├── claude_code.llm_request
├── claude_code.hook
└── claude_code.tool
    ├── claude_code.tool.blocked_on_user
    ├── claude_code.tool.execution
    └── subagent claude_code.llm_request / claude_code.tool

Bash/PowerShell receive TRACEPARENT when tracing is on. Custom providers do not receive it by default; explicitly enable propagation when required:

export CLAUDE_CODE_PROPAGATE_TRACEPARENT=1

#Analytics dashboard

PlanURLContent
Team/Enterprisehttps://claude.ai/analytics/claude-codeUsage, contributions, leaderboard and CSV
Console APIhttps://platform.claude.com/claude-codeUsage, spend and team insights

Contribution metrics require GitHub integration and organization settings. They cover assisted PRs, lines, acceptance and users. ZDR organizations see usage only.

Console analytics includes accepted lines, acceptance rate, activity, spend and user insights. Spend is an estimate; billing remains authoritative.

#Caching and cost effects

ActionEffect
Metrics/logsNo prompt changes; usually no cache effect
TracingNo prompt changes; possible export overhead
Raw content loggingNo cache effect but substantial privacy/storage risk
/usage and /costLocal/account display without prefix changes
Status-line costsLocal script, no model call

Optimize Passion8 costs with caching, cost controls and the Passion8 console, not only Anthropic analytics.

#Official references

Support

Need help?

For setup, billing, or model issues, email us. Check the status page for uptime.

WeChat / QQ support is available at the bottom right.