Blank white background with no objects or features visible.

We’re sharing complimentary access to the full Gartner Hype Cycle for AI Governance 2026. Get your copy →

Claude Code Observability: Track Tokens, Cost, and Usage per Developer

By Ashish Dubey

Updated: November 1, 2026

Published: October 31, 2026

TL;DR:

Observability for a coding agent is not about uptime. It is about answering one question per developer: what did this cost, and why.

  • The unit of observability is the token, split four ways — input, output, cache read and cache write — because your bill depends entirely on that mix.
  • The native /usage view is local to one machine and one session, so it can tell a developer what their last session cost but cannot give you a fleet number.
  • OpenTelemetry export is the native way to get per-user metrics off each machine and into your own stack — it works on every setup, including cloud providers.
  • Cloud-provider usage never reaches Anthropic's dashboards, so on Amazon Bedrock, Google Vertex or Microsoft Foundry you get attribution only through OpenTelemetry or a gateway.
  • An AI gateway makes the trail unavoidable: every request crosses one point, so per-developer traces, spend and model usage exist whether or not each laptop is instrumented.

What observability means for a coding agent

Traditional observability asks whether a service is up. A coding agent is always “up” — it runs on a laptop and talks to a model provider. The question that matters is economic and behavioural: which developer spent what, on which model, doing what, and why did one session cost ten times another. That is token accounting, not health checking, and it is the lens this guide uses. For the billing side of the same coin, see Claude Code Pricing Explained.

The stakes are concrete. A single active developer runs roughly $13 per active day and $150–250 per month, with about 90% of users under $30/day — so the exceptions matter enormously. Without a per-developer view you cannot find the three people in a team of thirty driving most of the invoice, or tell whether they are doing hard work or leaving Opus on by default. Observability turns a surprising total into a list of fixable causes.

What to actually track

Seven signals carry almost all the value. Everything else is derived from them.

SignalWhy it mattersWhere it comes from
Input / output tokensThe base of every cost figure; output is far pricier than inputEach API response
Cache read / write tokensCached reads are ~10x cheaper than fresh input — the split explains your billThe cache fields on each response
Cost per developerFinds the two or three outliers that drive most spendTokens priced per model, attributed to a user
Cost per modelSurfaces Opus-left-as-default wasteThe model served on each request
Cost per repo or teamChargebacks, per-team budgets, and trend linesRequest metadata or the routing key
Latency (ms)Slow calls, provider degradation, and timeout patternsThe request span timing
Tool calls and edit decisionsHow much agent work is accepted vs discardedThe tool-use events in each session

Two of these — the model mix and the cache ratio — are also your biggest cost levers, which is why observing them pays for itself. The routing side is covered in Opus vs Sonnet vs Haiku: a cost-vs-capability routing guide, and the caching side in Claude prompt caching: the real cost math.

The token is not one number — it is four

“Tokens used” is a useless aggregate because the four categories are priced wildly differently. On Opus 5.5 the gap is stark: output is five times the price of fresh input, cache writes cost more than fresh input, and cache reads cost a fraction of it. Collapsing them hides exactly the information you need to cut the bill.

Token typeWhat it isRelative cost (Opus 5.5)What a high value tells you
InputFresh prompt sent to the model$4 / M (baseline)Large or repeated context being re-sent
OutputTokens the model generates$20 / M (~5x input)Verbose generations or oversized tasks
Cache writeContext written into the cache$5 / M (above input)Normal on first turn; wasteful if churned
Cache readContext served from the cache$0.20 / M (~10x cheaper)Healthy — caching is working as intended

A high cache-read ratio is the signal you want: long-lived context reused instead of re-billed at full input price. On a subscription the prompt cache lives about an hour; on the API or a cloud provider it is roughly five minutes, so the ratio to expect differs by setup. If cache reads collapse and fresh input climbs, something broke the cache — and you only notice if the four numbers are tracked separately.

The native options, and where each one stops

Claude Code ships with real visibility — it is just scoped to the individual.

  • /usage in the CLI shows the current session's tokens and estimated cost, computed locally at list price. It is accurate for one developer on one machine, and it resets when the session is cleared. It cannot aggregate a team.
  • /insights summarises recent sessions on that machine — useful for a developer reflecting on their own patterns, still not a fleet view.
  • Subscription analytics (Teams and Enterprise) give an org-level spend report per user and per model, updated daily — good for finance, but not a live, per-request view.
  • Cloud-provider usage is invisible to Anthropic's dashboards. Run Claude Code on Amazon Bedrock, Google Vertex or Microsoft Foundry and the native analytics simply do not see it, because the tokens are billed to your cloud account instead.

The pattern is consistent: the native tools answer “what did I just spend,” not “what is the fleet doing right now.” For that, you need the metrics to leave the machine.

OpenTelemetry: getting metrics off the machine

The native way to close the gap is OpenTelemetry. Claude Code can export per-user token and cost metrics over OTLP to your own observability stack, and it works on every setup — subscription, Console API, or any cloud provider. That makes it the one native option that gives near-real-time per-developer numbers regardless of how developers authenticate.

Turning it on

Export is off by default and driven entirely by environment variables, set in the shell profile or a managed-settings file pushed to every machine. A minimal metrics-and-logs setup:

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=https://otel-collector.internal:4318
# optional: tighten the push cadence (milliseconds)
export OTEL_METRIC_EXPORT_INTERVAL=60000
export OTEL_LOGS_EXPORT_INTERVAL=5000

Metrics push on an interval — the default is 60000 ms for metrics, 5000 ms for logs — so “near-real-time” means minute-grained, not per-request. Traces are a separate beta signal gated behind CLAUDE_CODE_ENHANCED_TELEMETRY_BETA=1 and OTEL_TRACES_EXPORTER=otlp; enable them only with a collector ready to receive spans.

What each signal carries

OpenTelemetry emits three kinds of signal: metrics (the counters you build dashboards on), logs (discrete events), and traces (beta spans for a single interaction). The metrics are where the cost story lives:

MetricWhat it carriesKey attributes
claude_code.token.usageTokens consumed, split by categorytype (input / output / cacheRead / cacheCreation), model
claude_code.cost.usageEstimated spend at list price (USD)model, user.email
claude_code.session.countSessions startedsession.id, user.email
claude_code.lines_of_code.countLines the agent changedtype (added / removed)
claude_code.code_edit_tool.decisionWhether an edit was kepttool_name, decision (accept / reject)
claude_code.active_time.totalSeconds of active usetype (user / cli)
claude_code.commit.count / pull_request.countGit activity driven through the agentstandard attributes

Per-user attribution rides on the user.email and account-identifier attributes, included by default. Note that session.id raises cardinality sharply — one series per session — so if your backend charges by series, keep it off for fleet dashboards and attribute by user instead. The event logs (claude_code.user_prompt, claude_code.tool_result, claude_code.api_request) add per-action detail metrics cannot, and can optionally carry prompt or tool content — a privacy decision to make before enabling.

The trade-off is operational: you instrument every machine, keep the variables in place through laptop refreshes and new hires, and run the collector and dashboards yourself. It streams metrics well, but a metric stream is not a request-level audit trail, and it does nothing to enforce a budget — it only reports one. For a deeper treatment of the token accounting itself, see Observability for Claude in production: token accounting and tracing.

Native vs OpenTelemetry vs a gateway

Capability/usage (native)OpenTelemetry exportAI gateway
ScopeOne machine, one sessionPer-developer, fleet-widePer-developer, fleet-wide
Per-user attributionNoYesYes
Works on cloud providersLocal onlyYesYes
Request-level tracesNoPartial (beta)Yes
Latency per request (ms)NoPartialYes
Spend limits / enforcementNoNoYes
Cross-tool (Cursor, Codex)NoPer-tool onlyYes, one view
Setup costBuilt inInstrument every machinePoint the client at one endpoint

OpenTelemetry and a gateway are not mutually exclusive — a good gateway is OpenTelemetry-compliant and can feed the same stack. The difference is that the gateway also sits in the request path, so it can trace and cap, not just count. OTel is the right answer when you own the fleet, trust every machine to stay instrumented, and only need to report. A gateway is the right answer when machines come and go, when some traffic runs on a cloud provider, and when “see it” has to become “stop it.”

Observability at the TrueFoundry AI Gateway

Route Claude Code through the TrueFoundry AI Gateway and every completion crosses one point you control. That turns observability from something each developer opts into on each laptop into something that simply exists:

  • Request traces — each request with the resolved user, the model served, token counts and latency, so you can answer “who sent that, and what did it cost” after the fact.
  • Metrics dashboards that aggregate the fleet by user, team and model — the per-developer picture cost tracking for Claude Code walks through.
  • One view across tools — Claude Code, Cursor and Codex land in the same place instead of three, as in centralising cost control for AI coding IDEs.
  • OpenTelemetry-compliant export at roughly 3–4 ms of added overhead, so the same numbers flow into Grafana, Datadog or Prometheus if you already run them.
Want per-developer Claude Code spend without instrumenting every laptop?

What a single request trace records

A gateway answers questions OpenTelemetry metrics cannot because it logs each request as a discrete record, not a minute-bucketed counter. A trace captures the resolved identity, the model served, the four-way token split, the cost at your contracted rate, end-to-end latency in milliseconds, the status, and the routing decision. Because each row is searchable and retained, you can reconstruct a spike: filter to one developer and one hour, and read the actual calls that drove it — the audit trail a metric stream flattens away.

Trace fieldWhat it answers
Resolved user / keyWho sent this request
Model servedWas it Opus when Sonnet would do
Token split (in / out / cache)Where the cost in this call came from
Cost at contracted rateThe real spend, not a list-price estimate
Latency (ms)Was this call slow, and was the provider degraded
Routing decisionWhich policy chose this model

What to alert on, and the dashboards to build

Collecting signals is wasted if nobody looks until the invoice arrives. The point of getting metrics off the machine is to act while they still matter — a small set of alerts and a handful of dashboards, not a wall of graphs. Worthwhile alerts map to a specific, fixable cause:

  • Per-developer daily spend crossing a threshold — e.g. sustained above the ~$30/day that already covers about 90% of users. This catches the outlier on the day it starts, not a month later.
  • Opus share of tokens above a ceiling — the clearest signal of default-model drift, where routine edits are quietly running on the most expensive model.
  • Cache-read ratio falling — a sudden drop means caching regressed and fresh input is being re-billed at full price.
  • Latency p95/p99 in ms crossing a bound — surfaces provider degradation and timeout patterns before developers report them as “Claude is slow.”
  • Off-hours request volume — scheduled tasks and background work that re-send large context on an interval show up as spend with no human at the keyboard.

The dashboards worth standing up are equally few: fleet cost by developer (top-N), cost by model so the Opus-vs-Sonnet-vs-Haiku mix is visible at a glance, a stacked view of the four token types to watch the cache ratio, cost per repo or team for chargebacks, a latency distribution in milliseconds, and tool-call acceptance. On a gateway these are prebuilt and fed automatically; on OpenTelemetry you assemble them in Grafana or your backend from the metrics above.

A worked example

A platform team has thirty developers on Claude Code, some on the subscription and some on Bedrock. The monthly bill is climbing and nobody can say why. They point every install at the gateway and read the dashboard the next day: three developers account for 60% of token spend, all three because Opus is their default model, and one scheduled task is re-sending a large context every hour. They set a model policy that routes routine edits to Sonnet, fix the task, and the trend line bends — without asking anyone to run a command on their laptop. The observability did not change behaviour; seeing it did.

The honest limit: a gateway shows spend and lets you cap it. It does not rewrite prompts — it makes the waste impossible to miss and gives you the policy lever to act. The enforcement side is covered in Claude Code governance with an AI gateway.

Gotchas worth knowing

  • The /usage dollar figure is an estimate computed locally at list price. If your org pays contracted rates it will not match the invoice unless an admin sets the rate override.
  • /usage is per machine. A developer who codes on a laptop and a desktop sees two partial pictures; only an off-machine metric (OTel or a gateway) reconciles them.
  • Cloud-provider dashboards split the data. On Bedrock, Vertex or Foundry your spend lives in the cloud billing console, and per-user attribution needs OpenTelemetry or a gateway on top.
  • Idle sessions still generate requests. Scheduled tasks and background work re-send full context on their interval, so a quiet-looking developer can still accrue cost — you will only see it in a per-request trace.
  • Counting is not capping. OpenTelemetry tells you a budget was blown after the fact; only something in the request path can stop the request before it spends.
  • session.id is a cardinality trap. Left on for fleet dashboards it creates one metric series per session, which can balloon cost on a usage-priced observability backend — attribute by user instead.
  • Agent teams multiply tokens. Multi-agent runs use roughly 7x the tokens of a single session, so adopting them can make spend jump without any individual behaving differently.

Related reading

Conclusion

Claude Code observability is really cost observability with the detail turned up: tokens split four ways, attributed to a developer, a model and a task. The native tools answer it for one person on one machine; OpenTelemetry answers it for the fleet if you instrument every machine; and a gateway answers it for the fleet by default, because every request already passes through it.

Pick the layer that matches how far you need to see. If the answer is “per developer, across every model and provider, with the ability to act on what I find,” the request path is the place to stand.

See every Claude Code request, token and dollar in one place.

Try now.

One gateway for all your models, MCP servers, and agents.
No credit card needed.

Start free
Table of Contents

One Gateway for Every LLM, Agent and MCP Server

Book a 30-min with our AI expert

Book a Demo

The fastest way to build, govern and scale your AI

Book Demo
Summarize with
ChatGPT logo by OpenAI
Perplexity AI logo
Blurry red snowflake on white background, symmetrical frosty design with soft edges and abstract shape.

Discover More

No items found.
November 1, 2026
|
5 min read

Agent Identity and On-Behalf-Of (OBO) Delegation: Who Is Really Calling Your Tools?

No items found.
November 1, 2026
|
5 min read

AI Agent Identity with Microsoft Entra Agent ID: Issuing and Governing Agent Identities

No items found.
November 1, 2026
|
5 min read

Claude API Pricing: A Model-by-Model Cost Breakdown

No items found.
November 1, 2026
|
5 min read

The Identity-Broker Pattern for AI Agents: One Trust Boundary for Every Credential

No items found.
No items found.

Recent Blogs

Black left pointing arrow symbol on white background, directional indicator.
Black left pointing arrow symbol on white background, directional indicator.

Frequently asked questions

What is Claude Code observability?

It is visibility into what Claude Code consumes — tokens (input, output, cache read and write), cost, model usage and latency — ideally broken down per developer, per model and per team. The goal is to explain and control spend, not to monitor uptime.

How do I see Claude Code token usage?

Run /usage in the CLI for the current session on that machine. For a fleet view, export metrics with OpenTelemetry to your own stack, or route traffic through an AI gateway that records tokens and cost per request.

Can I track Claude Code cost per developer?

Yes, but not from /usage alone, which is per machine. Subscription plans give org-level spend reports; for live per-developer attribution across API keys and cloud providers, use OpenTelemetry export or an AI gateway that meters spend per key.

How do I set up Claude Code OpenTelemetry?

Set CLAUDE_CODE_ENABLE_TELEMETRY=1 plus the OTLP exporter and endpoint environment variables on each machine, then point them at your collector. Metrics push on an interval (default 60000 ms) and include claude_code.token.usage, claude_code.cost.usage and session, line-of-code and edit-decision counters, attributed by user and model.

Does observability work when Claude Code runs on Amazon Bedrock?

Not through Anthropic's own dashboards — cloud-provider usage does not reach them. You get per-user cost and token metrics on Bedrock, Vertex or Foundry through OpenTelemetry export or by routing the traffic through a gateway.

What is the difference between OpenTelemetry export and a gateway?

OpenTelemetry streams metrics from each machine into your stack — you instrument every machine and it reports, but does not enforce. A gateway sits in the request path, so it both traces every request and can apply spend limits and model policy. A gateway is usually OpenTelemetry-compliant, so you can have both.

How much overhead does gateway observability add?

On the TrueFoundry AI Gateway, roughly 3–4 ms per request, and the metrics are OpenTelemetry-compliant, so they flow into Grafana, Datadog or Prometheus without a separate pipeline.

Can I observe Claude Code, Cursor and Codex together?

Yes — if you route them through one gateway, all three land in the same traces and dashboards, giving a single per-developer cost view instead of three disconnected ones.

Take a quick product tour
Start Product Tour
Product Tour