updated October 3, 2026
Claude Code and OpenTelemetry: usage and cost metrics for a team
Set CLAUDE_CODE_ENABLE_TELEMETRY=1 and an OTLP exporter in Claude Code's managed settings, and every computer sends sessions, tokens, cost, lines changed, commits and pull requests, by person, every minute, to the collector you name. The text of prompts stays out unless you turn it on. Codex sends its events the same way from an [otel] section in its config.toml.
The settings
Claude Code reads these from the env block of its managed settings, which your device management puts on every computer, so it is on for everyone at once. Put your collector's address and token in place of the example's. The protocol can be grpc, http/json or http/protobuf, whichever your collector takes.
{
"env": {
"CLAUDE_CODE_ENABLE_TELEMETRY": "1",
"OTEL_METRICS_EXPORTER": "otlp",
"OTEL_LOGS_EXPORTER": "otlp",
"OTEL_EXPORTER_OTLP_PROTOCOL": "http/json",
"OTEL_EXPORTER_OTLP_ENDPOINT": "https://otel.example.com",
"OTEL_EXPORTER_OTLP_HEADERS": "Authorization=Bearer YOUR_TOKEN"
}
}Where the file goes
| System | File | Pushed by |
|---|---|---|
| macOS | /Library/Application Support/ClaudeCode/managed-settings.json | a configuration profile for the com.anthropic.claudecode domain (Jamf, Kandji, Intune) |
| Windows | C:\Program Files\ClaudeCode\managed-settings.json | the Settings value (this JSON as a string) under HKLM\SOFTWARE\Policies\ClaudeCode (Intune, Group Policy) |
| Linux and WSL | /etc/claude-code/managed-settings.json | the file itself (Ansible, Puppet, Chef) |
What it sends
Every 60 seconds, each computer sends these metrics, each with the session and the person's account: their email when they sign in with Claude.
| Metric | What it counts |
|---|---|
| claude_code.session.count | Sessions started |
| claude_code.token.usage | Tokens, by type (input, output, cache read, cache creation) and model |
| claude_code.cost.usage | Cost in US dollars, by model |
| claude_code.lines_of_code.count | Lines added and removed |
| claude_code.commit.count | Commits made |
| claude_code.pull_request.count | Pull requests opened |
| claude_code.code_edit_tool.decision | Edits accepted or rejected |
| claude_code.active_time.total | Time actively in use, in seconds |
The events
Events go out every 5 seconds, among them claude_code.user_prompt, claude_code.api_request (the model, tokens, cost and time of each request), claude_code.tool_result and claude_code.api_error. OTEL_METRIC_EXPORT_INTERVAL and OTEL_LOGS_EXPORT_INTERVAL change the timing, in milliseconds.
What stays private
- The text of prompts is left out unless OTEL_LOG_USER_PROMPTS=1: the event says a prompt was sent and how long it was.
- Claude's answers, tool arguments and tool output are left out too, unless OTEL_LOG_ASSISTANT_RESPONSES, OTEL_LOG_TOOL_DETAILS or OTEL_LOG_TOOL_CONTENT turn them on.
- Cost is worked out on the computer at list prices. If you pay contracted rates, the modelPricing managed setting (Claude Code 2.1.242 and later) makes the figures match them.
Codex
Codex sends its events from an [otel] section in its configuration, which device management puts in the places below. The lines after them send the events as JSON over HTTP with your token, and leave the text of prompts out.
| System | Where device management puts it | Against a person's own settings |
|---|---|---|
| macOS | /etc/codex/managed_config.toml, or a profile for com.openai.codex with the file as config_toml_base64 | over a person's own |
| Linux | /etc/codex/managed_config.toml | over a person's own |
| Windows | %ProgramData%\OpenAI\Codex\config.toml | a default: a person's own ~/.codex/config.toml can change it |
[otel] log_user_prompt = false [otel.exporter.otlp-http] endpoint = "https://otel.example.com/v1/logs" protocol = "json" [otel.exporter.otlp-http.headers] Authorization = "Bearer YOUR_TOKEN"
Where to send it
Any OpenTelemetry collector takes it: Datadog, Grafana with Prometheus and Loki, Honeycomb, SigNoz and others, some with a Claude Code dashboard to start from. You still match accounts to people and teams, put a price on seats, and build the views your managers and finance want.
Tokaware takes it as it is, on Business and up: make an ingest token in Settings, Collection, and copy the settings it gives you, already filled in for both tools. Usage then appears by person beside what the desktop app and the providers' bills report, with every limit and dollar by team and project. People signed in with Claude or ChatGPT are known by their email; for someone on an API key, add user.email to OTEL_RESOURCE_ATTRIBUTES. The text of a prompt is never kept, even when a computer sends it.
for your team
See your team's Claude Code and Codex in one place
Tokaware shows every session, limit and dollar across your developers, by person, team and project. Free for up to 3 people, and new teams get 14 days of Business, no card needed.
Questions people ask
- Does Claude Code send my prompts over OpenTelemetry?
- Not unless OTEL_LOG_USER_PROMPTS=1 is set. By default an event records that a prompt was sent and its length, not its text, and Claude's answers and tool output are left out as well.
- How often does Claude Code export metrics?
- Every 60 seconds for metrics and every 5 seconds for events, changed with OTEL_METRIC_EXPORT_INTERVAL and OTEL_LOGS_EXPORT_INTERVAL in milliseconds.
- Does it work on Amazon Bedrock or Google Cloud?
- Yes. The telemetry is sent from each developer's computer, whichever way Claude Code is billed, which makes it the way to see per-person usage on cloud providers.
- Which OTLP protocol should I use?
- Whichever your collector takes: Claude Code sends grpc, http/json or http/protobuf, set with OTEL_EXPORTER_OTLP_PROTOCOL.