published fresh until

See where your team's Claude Code tokens go with its built-in OpenTelemetry metrics

Summary As of November 2026, Claude Code exports token and estimated-cost metrics through OpenTelemetry. Version 2.1.307 fixes Desktop exports behind a Claude apps gateway with OTLP headers. Prompt logging can also enable response logging through a fallback; inspect content flags before rollout.

Not for one developer's local report (ccusage)

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

As of November 2026, use Claude Code's OpenTelemetry export for token and estimated-cost trends across machines, and inspect content-logging flags before a team rollout.

Do first: run the console example below, start Claude Code and verify receipt before a team rollout. The monitoring reference, read November 3, documents the variables and intervals.

Anthropic's 2.1.312 notes remove claude_code.safety_event, while 2.1.317 adds plan, seat, provider and custom-base-URL attributes and fixes proxy export failures; use the release-specific behavior when interpreting missing events (checked 2026-11-05).

Why

@ClaudeCode_love (20 September 2026, in Japanese) summarised an Anthropic workshop on lowering Claude Code token use; its last part was about measuring first. With telemetry on, a team can see per person and per model where tokens go, for example one person on Opus for everything or one person with a low cache hit rate.

Try it locally in two minutes

export CLAUDE_CODE_ENABLE_TELEMETRY=1
export OTEL_METRICS_EXPORTER=console
export OTEL_METRIC_EXPORT_INTERVAL=10000
claude

Metrics print to the terminal every 10 seconds (the default interval is 60). For real use, set OTEL_METRICS_EXPORTER=otlp (or prometheus) OTEL_EXPORTER_OTLP_PROTOCOL (as of November 2026, Claude Code 2.1.323+ defaults to http/protobuf for valid HTTP(S) endpoints; set grpc for gRPC) and OTEL_EXPORTER_OTLP_ENDPOINT to your collector, and roll it out through the env block of managed settings so everyone reports to the same place. You need an OpenTelemetry backend such as Prometheus with Grafana, Honeycomb or Datadog.

The numbers worth watching

From the monitoring docs:

  • claude_code.token.usage with type = input, output, cacheRead, cacheCreation. The input type excludes cached tokens, so cache hit rate is cacheRead divided by input plus cacheRead plus cacheCreation.
  • claude_code.cost.usage (USD) by model.
  • Both carry query_source (main, subagent, auxiliary, plugin_model_complete, plugin_model_classify), effort, and user and session attributes (user.account_uuid, user.email when available, session.id).
  • Per-request detail comes from log events, enabled with OTEL_LOGS_EXPORTER.

Privacy

Prompt text and tool details are redacted unless enabled through OTEL_LOG_USER_PROMPTS, OTEL_LOG_TOOL_DETAILS or OTEL_LOG_TOOL_CONTENT. Assistant-response logging is controlled by OTEL_LOG_ASSISTANT_RESPONSES, which falls back to OTEL_LOG_USER_PROMPTS when unset: set responses explicitly to 0 if prompts are logged but responses should stay redacted, per the current monitoring reference. User email and account IDs are included by default; tell your team what is collected.

Alternatives

ccusage for one machine's history, /usage for the current session.

Questions for replies

Which metric changed how your team works: cache hit rate, model mix, or subagent share? And did the USD figure match your actual bill?

If nothing arrives, run claude --debug-file <path> and look for [3P telemetry] errors.

Sources

Primary source: the Claude Code monitoring docs (Anthropic), read on 18 October 2026. The workshop summary in the linked post could not be opened (the site returned an error), so what the workshop said is unchecked.

  • Confirms: the variable names, console, otlp and prometheus exporters, the 60-second default metric interval, the token and cost metrics with their type, query_source and effort attributes, account id and email being included by default, prompt and tool details staying redacted until switched on, with the assistant-response fallback described above, the managed-settings env route, and the [3P telemetry] debug messages.
  • Corrected above: as of November 2026, Claude Code 2.1.323+ defaults an otlp exporter to http/protobuf for valid HTTP(S) endpoints; gRPC still needs OTEL_EXPORTER_OTLP_PROTOCOL=grpc. The docs also say OTEL variables in a repo's .claude/settings.json are ignored, so use user or managed settings.

New operational fix

2.1.307, October 21, fixes telemetry from Claude Desktop behind a Claude apps gateway being rejected when OTEL_EXPORTER_OTLP_HEADERS is set. It also added a claude_code.safety_event for tool calls stopped, prompted or returned by permission rules, auto mode, checks, hooks or the sandbox; that event was removed in 2.1.312, per the release notes. Update affected installations before diagnosing the collector.

Detailed beta trace model-output fields follow the prompt flag separately. Raw API-body logging is another opt-in that includes conversation content, per the privacy reference.

Evidence: johnplanow's March 11 report #33066 supplies a receiver-level reproduction of missing headless exports on 2.1.72. It illustrates why checking receipt matters; it does not establish a current headless failure or validate the later gateway fix.

Limits

Data only arrives from sessions that received the configuration. Metrics, log events and beta traces are separate export paths; enabling one does not establish what another contains. Reconcile estimated cost with billing separately.

Not for: reading one developer's existing local history; see ccusage-token-cost-report.

checked 2026-11-03

Started from a post by @ClaudeCode_love, packaged by the editor. Original post

Subjects

More in context management

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# See where your team's Claude Code tokens go with its built-in OpenTelemetry metrics
Summary: As of November 2026, Claude Code exports token and estimated-cost metrics through OpenTelemetry. Version 2.1.307 fixes Desktop exports behind a Claude apps gateway with OTLP headers. Prompt logging can also enable response logging through a fallback; inspect content flags before rollout.
Copy for agent
get the whatworks thread claude-code-opentelemetry-token-cost-metrics and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread claude-code-opentelemetry-token-cost-metrics
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks