Claude Code in the team: how to measure cost, tokens and real usage with OpenTelemetry

What Claude Code exports on its own, how to roll telemetry out to a whole team, which metrics answer which question and how to judge value without building a surveillance tool.

Obseria TeamObseria
Summary
  • Claude Code has a built-in OpenTelemetry exporter that reports cost, tokens, sessions, active time, code changes, commits, pull requests and edit decisions once telemetry is switched on.
  • Roll the configuration out through settings files and add a department resource attribute, so spend can be broken down by team instead of appearing as one monthly total.
  • Treat the data as a cost and adoption signal aggregated per team, keep prompt content switched off, agree on the purpose with developers and the works council, and avoid turning output metrics into a productivity score.

Coding agents such as Claude Code have moved from individual experiments to tools that whole engineering departments use every day. They read repositories, edit files, run tests and open pull requests. For engineering leads and platform teams this raises practical questions that the monthly invoice does not answer: Which teams use the agent and how much? Which models drive the spend? Are developers accepting the edits or rejecting most of them? And is the investment paying off?

This article explains how to answer those questions with data. It covers what Claude Code exports by itself over OpenTelemetry, how to roll the configuration out to a team, which metric answers which question, a sensible dashboard and alert setup, privacy and works council considerations in Germany, and how to judge value without turning telemetry into a productivity ranking. A checklist at the end summarises the steps. Obseria is an independent observability platform and is not affiliated with Anthropic; the setup described here works with any OTLP-compatible backend.

Why coding agent cost is invisible without telemetry

Traditional developer tools have a fixed price per seat. Coding agents are different: their cost depends on how they are used. A short question about a function costs little. A long session that reads dozens of files, runs a test suite several times and iterates on a failing build can consume a large number of tokens. Two developers with the same licence can produce very different spend.

Without telemetry, you typically see only an aggregated amount per billing period. That number does not tell you which team, which model or which kind of task caused it. A rising bill can mean wider adoption, a few sessions that went in circles or a team that switched to a more expensive model; only usage data lets you tell these apart.

The second blind spot is value. Spend alone says nothing about whether the agent helps. To have a grounded discussion about return on investment, cost has to sit next to adoption (who uses it, how often) and output (what came out of the sessions).

What Claude Code exports by itself

Claude Code is unusual among developer tools because it ships its own OpenTelemetry exporter. Once telemetry is switched on, it sends metrics and log events over OTLP to any compatible backend. There is no wrapper, no SDK to install and no proxy in front of the model API. Telemetry is off until you opt in.

Metrics

  • claude_code.cost.usage: spend in US dollars, split by model
  • claude_code.token.usage: tokens by type, namely input, output, cache read and cache creation
  • claude_code.session.count: sessions started
  • claude_code.active_time.total: time actually spent working with the agent, not wall-clock time
  • claude_code.lines_of_code.count: lines added and removed
  • claude_code.commit.count: commits created through Claude Code
  • claude_code.pull_request.count: pull requests created through Claude Code
  • claude_code.code_edit_tool.decision: edits accepted versus rejected

Events

  • claude_code.api_request: one log event per model request with model, duration, tokens and cost
  • claude_code.tool_result: one log event per tool call with tool name, success and duration

Metrics give you trends and totals; events give you the detail to explain an outlier, for example a single session with an unusual number of requests. One note on accuracy: the cost values are estimates that Claude Code calculates and reports. For the authoritative amount, check the billing of your model provider.

Step by step: setting up Claude Code telemetry for a team

Step 1: Switch telemetry on and point it at your backend

For a first test, export the following variables in the shell you start Claude Code from. Replace the endpoint and token with the values of your observability backend.

# 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
# Attribute spend to a team or cost centre
export OTEL_RESOURCE_ATTRIBUTES="department=platform-team"

claude

Delta temporality is the default for Claude Code. Setting it explicitly protects you from a global OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE on the machine switching it to something else, which would make counters add up incorrectly.

Step 2: Add a team or cost centre attribute

The department resource attribute is what turns one total into a breakdown. Without it, you can see spend per model, but not per team. Agree on a short, stable list of values (for example the names of your engineering teams or cost centres) before the rollout, so that dashboards do not end up with five spellings of the same team.

Step 3: Make it stick with settings files

Environment variables disappear when the shell closes and depend on every developer remembering them. For a team rollout, put the same values into the env block of a settings file. Use ~/.claude/settings.json for a single machine, or a repository's .claude/settings.json, so everyone working in that repository reports automatically.

{
  "env": {
    "CLAUDE_CODE_ENABLE_TELEMETRY": "1",
    "OTEL_METRICS_EXPORTER": "otlp",
    "OTEL_LOGS_EXPORTER": "otlp",
    "OTEL_EXPORTER_OTLP_PROTOCOL": "http/protobuf",
    "OTEL_EXPORTER_OTLP_ENDPOINT": "https://your-otlp-endpoint",
    "OTEL_EXPORTER_OTLP_HEADERS": "Authorization=Bearer YOUR_TOKEN",
    "OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE": "delta",
    "OTEL_RESOURCE_ATTRIBUTES": "department=platform-team"
  }
}

If you commit the repository variant, think about the token: use an ingest token that can only write telemetry, not one with read access to your observability data.

Step 4: Verify, then reset the test interval

Metrics are exported on a one-minute interval by default, which makes a first test feel broken. While testing, shorten the interval, run a prompt or two and check that data arrives:

export OTEL_METRIC_EXPORT_INTERVAL=5000
export OTEL_LOGS_EXPORT_INTERVAL=5000

Remove these settings again afterwards. A five-second interval across a whole team generates a lot of needless traffic.

Which metric answers which question

The exported signals map well onto the questions engineering leads actually ask. The table below is a starting point for your dashboard.

QuestionSignalHow to read it
What does Claude Code cost us per team?claude_code.cost.usage grouped by departmentTrend per week or month; compare teams relative to their size
Which models drive the spend?claude_code.cost.usage by modelCheck whether expensive models are used for tasks a smaller one could handle
Why do similar sessions cost so differently?claude_code.token.usage by typeThe split between cache read, cache creation and fresh input explains much of it
Is the tool actually adopted?claude_code.session.count, claude_code.active_time.totalSessions and active time per team over time, not per individual
Are the suggestions useful?claude_code.code_edit_tool.decisionRatio of accepted to rejected edits per team or repository
What comes out of the sessions?claude_code.lines_of_code.count, claude_code.commit.count, claude_code.pull_request.countOutput context for cost, never a target on its own
Why was this one session so expensive?claude_code.api_request eventsNumber of requests, models, tokens and duration within the session
Which tools fail or slow the agent down?claude_code.tool_result eventsSuccess rate and duration per tool name

A sensible dashboard and alerts

Dashboard layout

Keep the first version small. Five panels cover most needs:

  1. Overview: spend, tokens, sessions and active users for the selected period, with a trend line
  2. Cost by team and model: stacked by department and model, so shifts become visible
  3. Token mix: input, output, cache read and cache creation over time
  4. Output and acceptance: lines changed, commits, pull requests and the accepted versus rejected edit ratio
  5. Most expensive sessions: a table built from claude_code.api_request events, sorted by cost, with a drill-down into the requests

The most expensive sessions table is often the most useful panel. Sessions that consumed far more than usual frequently point to tasks that went in circles: missing project instructions, a test that never passes, or a repository the agent has to read in full every time. That is actionable feedback for the team, not for an individual.

Alerts

  • Spend spike: daily cost per team clearly above its own recent baseline. Use a relative threshold per team rather than one fixed amount for everyone.
  • Unusual session: a single session whose cost or number of API requests is far above the typical session. This catches runaway loops early.
  • Model shift: the share of spend on a particular model changes noticeably within a short period, for example after a configuration change.
  • Telemetry gap: a team that normally reports goes silent. This usually means a settings file was changed or a token expired, not that usage stopped.

Route these alerts to the platform team or the budget owner, not to individual developers. To keep them from becoming noise, the principles from our article on how to reduce alert fatigue apply here as well.

Privacy and works council aspects in Germany

Telemetry about developer tools is personal data as soon as it can be linked to a person. Metrics from Claude Code can be associated with user identity such as an account or email address. In Germany, a system that is objectively suitable for monitoring employee behaviour or performance is typically subject to co-determination by the works council. The following points are not legal advice, but they help to set up the topic in a way that is transparent and proportionate.

  • Prompt content stays off by default. Claude Code exports counts, costs, durations and tool names, not the text of prompts. Prompt text is only included if OTEL_LOG_USER_PROMPTS=1 is set explicitly. Leave it unset unless your organisation has made a deliberate, documented decision and informed developers.
  • Define the purpose first. Write down why you collect the data, for example cost allocation, budget planning and evaluating the tool. Data collected for cost allocation should not quietly become a basis for performance reviews.
  • Aggregate per team. For most questions, a breakdown by department and model is sufficient. Restrict per-person views to the few roles that genuinely need them, for example to resolve a billing question, and control this through permissions.
  • Set retention. Agree on how long detailed events are kept and keep aggregated metrics longer if needed.
  • Involve developers and the works council early. Explain what is collected, show the dashboard and document the agreement. Transparency makes adoption easier.

Where your telemetry is stored also matters for this discussion. Obseria keeps data in the EU, and its pipeline can mask personal data before storage.

How to judge value without a productivity score

Once output metrics are available, it is tempting to divide lines of code by cost and rank teams or people. Resist it. Lines changed say little about value: a good refactoring can remove more lines than it adds, and a large generated diff may create review work rather than save time.

A more useful approach is to look at several signals together, per team and over time:

  • Adoption: are sessions and active time stable or growing after the initial curiosity wears off?
  • Acceptance: is the share of accepted edits rising as teams improve project instructions and repository setup?
  • Delivery: do commits and pull requests created with Claude Code make it through review? Combine this with your existing delivery metrics, for example DORA metrics, rather than inventing new ones.
  • Cost per outcome, as a trend: cost per pull request or per commit is useful to spot changes within a team over time, not to compare people.
  • Qualitative feedback: ask teams where the agent helps and where it does not. The numbers tell you where to look; conversations tell you why.

Telemetry also has a second direction. Through the Obseria MCP server, Claude Code can read logs, traces, metrics and problems while it works, for example to check the error rate of the service it is editing. And with AI Code Insights, incidents can be linked to the pull requests and coding agents that introduced a change, which adds a quality perspective to the cost perspective.

Checklist

CLAUDE CODE TELEMETRY ROLLOUT CHECKLIST

Preparation
[ ] Purpose documented (cost allocation, budget, tool evaluation)
[ ] Developers and works council informed; agreement documented
[ ] List of department / cost centre values agreed
[ ] Ingest-only token created for telemetry

Setup
[ ] CLAUDE_CODE_ENABLE_TELEMETRY=1
[ ] OTEL_METRICS_EXPORTER=otlp and OTEL_LOGS_EXPORTER=otlp
[ ] OTEL_EXPORTER_OTLP_ENDPOINT and OTEL_EXPORTER_OTLP_HEADERS set
[ ] OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE=delta
[ ] OTEL_RESOURCE_ATTRIBUTES="department=..." set
[ ] Values in ~/.claude/settings.json or the repo's .claude/settings.json
[ ] OTEL_LOG_USER_PROMPTS left unset
[ ] Test intervals removed after verification

Dashboards and alerts
[ ] Overview, cost by team and model, token mix
[ ] Output and accepted vs. rejected edits
[ ] Most expensive sessions with drill-down
[ ] Alerts: spend spike, unusual session, model shift, telemetry gap
[ ] Per-person views restricted by permissions; retention set

Review
[ ] Monthly look at trends per team, not rankings
[ ] Findings turned into better project instructions

How Obseria helps

Obseria is an OpenTelemetry-native observability platform hosted in the EU. It receives Claude Code metrics and events over OTLP and shows them in AI Monitoring: spend, tokens, sessions and active users at a glance, cost by model, person and team, the most expensive sessions, output and edit decisions. The Claude Code integration describes the setup in detail, and the AI observability overview shows how coding agent telemetry fits together with LLM monitoring for your own applications, which our LLM observability guide covers in depth.

If you want to see your own Claude Code usage, start a free trial or book a demo with our team.

Share

Observability that delivers answers.

Start for free with OpenTelemetry, no credit card required.