claude_code_cost_usage_USD_total OTEL counter collides across parallel processes sharing the same session_id, producing oscillating values and inflating increase() queries by 100×+

Open 💬 3 comments Opened May 5, 2026 by yoavfeld

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

Claude Code emits claude_code_cost_usage_USD_total from multiple processes (likely multiple --resume instances) without a process-distinguishing label, causing collisions in
any time-series backend.

jsonl file of the session:
25554c44-43fd-4d31-beb2-905547620336_jsonl.csv

cost reports that were received in Prometheus from Claude Code:
25554c44-session-metrics-2026-04-27.csv

What Should Happen?

Add pid or instance_uuid to the label set, or aggregate to a single per-session emitter.

Error Messages/Logs

Steps to Reproduce

  1. Configure Claude Code OTEL export to a Prometheus-compatible backend (Mimir, Prometheus, etc.) per the https://docs.anthropic.com/en/docs/claude-code/monitoring-usage. Confirm cumulative temporality at both the Claude Code

OTEL SDK and the OTEL collector.

  1. In one terminal (e.g., PyCharm), run claude --resume <session-id> and start working — make a few prompts that incur cost.
  2. Without exiting the first instance, in a second terminal of the same terminal_type (another PyCharm window) run claude --resume <session-id> against the same session UUID. Issue a few more prompts.
  3. After both processes have emitted at least one OTEL export interval (~60s), query the metric in your TSDB:

claude_code_cost_usage_USD_total{session_id="<session-id>"}

  1. Sample at fine resolution (step=2s over a 5-minute window).

Claude Model

Not sure / Multiple models

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

2.1.126

Platform

Anthropic API

Operating System

Ubuntu/Debian Linux

Terminal/Shell

Other

Additional Information

_No response_

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗