claude-code - 💡(How to fix) Fix [Bug] OTel `query_source` attribute missing on `api_request` events and `cost.usage`/`token.usage` metric counters since 2026-05-13 (affects both claude-code and cowork) [1 pull requests]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Fix Action

Fixed

RAW_BUFFERClick to expand / collapse

Bug Description

The query_source attribute on claude_code.api_request log events AND claude_code.cost.usage / claude_code.token.usage counter metric datapoints became empty for all clients in our org starting 2026-05-13, after working correctly between 2026-05-09 and 2026-05-12.

This affects both claude-code CLI and cowork (Agent SDK) — same cutover date in both products — which points to a regression in the shared Anthropic Agent SDK telemetry layer rather than a CLI-specific issue.

Same failure class as #56098 (cost_usd missing in v2.1.122+) — a silent telemetry-attribute drop in a minor version.

Environment

  • Claude Code CLI versions observed on user machines: 2.1.128 to 2.1.143
  • Cowork: configured via Anthropic web Managed Settings, OTLP http/json
  • Pipeline: Anthropic clients → OTLP HTTPS → caddy → otel-collector v0.151.0 → ClickHouse 24.10
  • ~30 active CLI users + Cowork web sessions in our EU org
  • OTel resource attributes set via Managed Settings: source=claude-code / source=cowork, deployment.environment=managed, plus team/org identifiers

Evidence — query_source per day, per ServiceName (api_request events)

Query: SELECT toDate(Timestamp) d, ServiceName, count() total, countIf(LogAttributes['query_source'] = '') empty FROM otel_logs WHERE LogAttributes['event.name'] = 'api_request' AND Timestamp >= '2026-05-09' GROUP BY d, ServiceName

Dateclaude-code totalclaude-code emptycowork totalcowork empty
09.051130(none)
10.052760130
11.0525001,266113
12.0536,64318,643 (51 %)1,066643 (60 %)
13.0515,26515,265 (100 %)903903 (100 %)
14.052,3352,335 (100 %)748748 (100 %)
15.051,4401,440 (100 %)521521 (100 %)
16.05106106 (100 %)9595 (100 %)
17.053737 (100 %)1010 (100 %)

Identical cutover date in both products = SDK-layer regression.

Evidence — also affects metric counters

Same pattern on claude_code.cost.usage and claude_code.token.usage counter datapoints (via otel_metrics_sum):

Datecost.usage with qsrccost.usage emptysample values when populated
09.05360['main', 'subagent']
10.051190['main', 'subagent', 'auxiliary']
11.051,237112['main', 'subagent', 'auxiliary']
12.052,1821,939['main', 'subagent', 'auxiliary']
13.0502,645[]
14.0501,043[]
15.050853[]
16.050122[]
17.05037[]

Per the docs at https://code.claude.com/docs/en/monitoring-usage

  • Section "API request event": query_source is documented as free-form, with values like "repl_main_thread", "compact", or a subagent name
  • Section "Cost counter" / "Token counter": query_source is documented as an enum: "main", "subagent", or "auxiliary"

Both event-level AND metric-level query_source are missing in our post-2026-05-13 data — confirms the bug crosses both telemetry streams.

Cowork docs explicitly state: "Cowork reuses Claude Code's OTel events schema via the Claude Agent SDK." This confirms the shared SDK origin.

Impact

  • Cannot distinguish main-thread vs subagent vs auxiliary spend per user/team
  • Breaks per-subagent cost attribution dashboards for org-wide observability
  • Likely also breaks agent.name, skill.name, plugin.name, marketplace.name (not yet verified by us)
  • Affects both Claude Code CLI and Cowork users

Suggested

  1. Restore query_source attribute emission in the shared Agent SDK telemetry layer (both events and metric datapoints)
  2. Add a CI assertion that query_source is populated on:
    • claude_code.api_request log events
    • claude_code.cost.usage metric counter datapoints
    • claude_code.token.usage metric counter datapoints
  3. Document in the changelog when telemetry attributes are removed or renamed (#54172, #58125, #54473 all flag the same docs-lag pattern)

Related

  • #56098 — same failure mode for cost_usd field in v2.1.122+
  • #58674 — skill_activated event emits custom_skill instead of actual skill name (same 13.05. cutover)
  • #58439 — hook_execution_start events dropped before logger initialized
  • #54172, #58125, #54473, #54471, #51780, #25433 — recurring OTel attribute / docs lag pattern

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix [Bug] OTel `query_source` attribute missing on `api_request` events and `cost.usage`/`token.usage` metric counters since 2026-05-13 (affects both claude-code and cowork) [1 pull requests]