Claude Code monitoring: cost, usage and output of your coding agents
by Obseria · AI and LLMs- OpenTelemetry
- AI Observability
- AI and LLMs
- Category
- AI and LLMs
- Key metrics
- 10
- Ready-made
- 5 dashboards & alerts
- Setup
- 3 steps
- Standard
- OTLP
Claude Code exports OpenTelemetry on its own. Set a few environment variables and Obseria shows spend, tokens, sessions, code changes and tool decisions per person, team and model.
Native telemetry, nothing to install
Claude Code has a built-in OpenTelemetry exporter. No wrapper, no proxy in the path, only environment variables or a settings file.
Spend you can attribute
Cost and tokens split by model, person and team show where agent usage goes, instead of one total at the end of the month.
Adoption and output side by side
Sessions, active time, lines of code, commits, pull requests and accepted edits show how teams actually use the agent.
Obseria interface



Ready the moment data arrives
- Spend overview: cost, tokens, sessions, active users
- Cost by model, person and team
- Productivity: lines of code, commits, pull requests
- Tool calls and edit decisions
- Most expensive sessions and failed requests
What Obseria shows for Claude Code
Cost and tokens
Spend and token usage per session, person, team and model, including cache reads and cache creation.
Sessions and active time
How many sessions start and how much time is spent working, not wall-clock time.
Productivity
Lines added and removed, commits and pull requests created with Claude Code.
Tool calls and edit decisions
Which tools the agent runs, how often they succeed, and how many edits developers accept or reject.
API requests and failures
Per request model, duration, tokens and cost, plus failed requests for troubleshooting.
The other direction via MCP
Connect Claude Code to the Obseria MCP server so it can read logs, traces, metrics and problems while it works.
The Claude Code signals that matter
Obseria collects these values automatically and shows them in ready-made dashboards and alerts.
| Metric | Unit | What it tells you |
|---|---|---|
claude_code.cost.usage | USD | Spend per session, split by model; the basis for budgets and cost per team. |
claude_code.token.usage | {token} | Tokens by type: input, output, cache read and cache creation. |
claude_code.session.count | {session} | Sessions started, the simplest adoption signal per person and team. |
claude_code.active_time.total | s | Time actually spent working with Claude Code, not wall-clock time. |
claude_code.lines_of_code.count | {line} | Lines of code added and removed by the agent. |
claude_code.commit.count | {commit} | Commits created through Claude Code. |
claude_code.pull_request.count | {pull_request} | Pull requests created through Claude Code. |
claude_code.code_edit_tool.decision | {decision} | Edits accepted versus rejected, a direct signal of how useful suggestions are. |
claude_code.api_request | event | Log event per model request with model, duration, tokens and cost. |
claude_code.tool_result | event | Log event per tool call with tool name, success and duration. |
Set up Claude Code monitoring in minutes
- 1
Turn telemetry on
Set CLAUDE_CODE_ENABLE_TELEMETRY=1, OTEL_METRICS_EXPORTER=otlp and OTEL_LOGS_EXPORTER=otlp in the shell you start Claude Code from.
- 2
Point it at Obseria
Set OTEL_EXPORTER_OTLP_ENDPOINT and OTEL_EXPORTER_OTLP_HEADERS to your Obseria endpoint and token, optionally with a department resource attribute.
- 3
Roll it out to the team
Put the same variables into the env block of ~/.claude/settings.json or a repository's .claude/settings.json, then open AI Monitoring in Obseria.
# Claude Code exports OpenTelemetry natively, nothing to install.
export CLAUDE_CODE_ENABLE_TELEMETRY=1
export OTEL_METRICS_EXPORTER=otlp
export OTEL_LOGS_EXPORTER=otlp
export OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf
export OTEL_EXPORTER_OTLP_ENDPOINT=${OBSERIA_OTLP_ENDPOINT}
export OTEL_EXPORTER_OTLP_HEADERS="Authorization=Bearer ${OBSERIA_TOKEN}"
export OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE=delta
# Optional: attribute spend to a team or cost centre
export OTEL_RESOURCE_ATTRIBUTES="department=platform-team"
# Prompt text is not exported unless you set OTEL_LOG_USER_PROMPTS=1.
claudeWhy Claude Code monitoring matters
Coding agents have moved from experiments to daily tools. Claude Code runs in the terminal, reads repositories, edits files, runs commands and opens pull requests. For engineering leads this raises new questions: How much does agent usage cost per team? Which models are used? Do developers accept the edits, or reject most of them? Without data, the only answers are the monthly bill and anecdotes. Claude Code monitoring answers them with numbers.
Claude Code is unusual among developer tools because it exports OpenTelemetry itself. Once telemetry is switched on, it sends metrics and log events over OTLP to any compatible backend. There is no wrapper, no proxy in front of the model API and no change to how developers work. That makes Claude Code telemetry one of the simplest AI integrations to set up.
What Claude Code sends
The built-in exporter emits a focused set of metrics and events. These are the ones Obseria uses:
- Cost:
claude_code.cost.usagereports spend in US dollars, split by model. It is the basis for cost per team and for budgets. - Tokens:
claude_code.token.usagebreaks usage down into input, output, cache read and cache creation tokens. - Adoption:
claude_code.session.countandclaude_code.active_time.totalshow how often and how long the agent is actually used. - Output:
claude_code.lines_of_code.count,claude_code.commit.countandclaude_code.pull_request.countshow what comes out of those sessions. - Quality of suggestions:
claude_code.code_edit_tool.decisioncounts accepted and rejected edits. - Events:
claude_code.api_requestrecords each model request with model, duration, tokens and cost, andclaude_code.tool_resultrecords each tool call with name, success and duration.
Understanding Claude Code cost
Agent sessions differ widely. A short question costs little, while a long session that reads many files and iterates on failing tests can consume a large number of tokens. Looking at Claude Code cost per session, not only per month, shows where spend concentrates. The most expensive sessions are often the ones where a task went in circles, which is useful feedback for prompts, project instructions and repository structure.
Cache tokens matter as well. Claude Code reuses context through prompt caching, and the split between cache reads, cache creation and fresh input explains why two sessions of similar length can have very different cost. Splitting spend by model shows whether expensive models are used for tasks a smaller model could handle.
Attributing usage to teams
A single total is hard to act on. Add a resource attribute such as department=platform-team through OTEL_RESOURCE_ATTRIBUTES, and Obseria breaks spend and usage down by team. Because the exporter reads standard OpenTelemetry variables, you can put the configuration into a repository's .claude/settings.json so everyone working on that repository reports automatically, or into ~/.claude/settings.json for a single machine.
Privacy and what is not exported
Telemetry is off until you opt in. Once enabled, prompt text is not exported by default: counts, costs, durations and tool names travel, but not the content of prompts. Setting OTEL_LOG_USER_PROMPTS=1 would add prompt text, so leave it unset unless your organization has decided it wants that and has informed developers. Metrics can be associated with user identity such as account or email, so treat per-person views as personal data, agree on their purpose with your team and works council where required, and restrict access through permissions. Obseria keeps data in the EU.
Best practices for Claude Code telemetry
- Roll out the settings through a repository or a central settings file, so reporting does not depend on individual shells.
- Always set a team or cost centre attribute, otherwise spend stays one undifferentiated number.
- Keep the default export interval in production; shorten
OTEL_METRIC_EXPORT_INTERVALonly while testing. - Keep the delta temporality that Claude Code uses by default, so counters add up correctly.
- Review the most expensive sessions regularly and turn the findings into better project instructions.
How Obseria helps with Claude Code monitoring
Obseria receives Claude Code metrics and events over OTLP and presents them in AI Monitoring: spend, tokens, sessions, active users and active time at a glance, cost by model, person and team, session depth, productivity, tool calls, edit decisions, model comparison, failures and recent calls. In the other direction, the Obseria MCP server lets Claude Code read logs, traces, metrics and problems, so the agent can check the error rate of the service it is editing. Obseria also links incidents to the pull requests and coding agents that created the change. Obseria is an independent product and is not affiliated with Anthropic.
Learn more
What is LLM observability?
What is LLM observability? How to trace LLM apps, RAG and AI agents, which metrics matter (tokens, cost, latency, quality) and OTel GenAI conventions.
What is observability?
What is observability? Learn how metrics, logs, traces and profiles let you understand any system state, how it differs from monitoring, and how to start.
Claude Code monitoring FAQ
No. Claude Code has a built-in OpenTelemetry exporter. You set CLAUDE_CODE_ENABLE_TELEMETRY=1, the OTLP exporters and the Obseria endpoint and token, then start claude.
Not by default. Only counts, costs, durations and tool names are exported. Prompt text is added only if you explicitly set OTEL_LOG_USER_PROMPTS=1.
Put the variables into the env block of a repository's .claude/settings.json or each developer's ~/.claude/settings.json. Add a department resource attribute to break spend down by team.
Metrics are exported on a one-minute interval by default. For a first test, set OTEL_METRIC_EXPORT_INTERVAL and OTEL_LOGS_EXPORT_INTERVAL to 5000 and remove them again afterwards.
Yes. Connect Claude Code to the Obseria MCP server with claude mcp add. The agent can then query logs, traces, metrics and problems with the same permissions as its user.
The telemetry settings are independent of the model provider, so the same exporter configuration applies. Cost values are estimates reported by Claude Code; check your provider billing for the authoritative amount.
Start monitoring Claude Code today
Connect Claude Code in minutes with OpenTelemetry or the Obseria Agent. Free for 14 days.