[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)

Open 💬 3 comments Opened May 17, 2026 by mguttmann

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

| Date | claude-code total | claude-code empty | cowork total | cowork empty |
|-------|------------------:|------------------:|-------------:|-------------:|
| 09.05 | 113 | 0 | (none) | — |
| 10.05 | 276 | 0 | 13 | 0 |
| 11.05 | 250 | 0 | 1,266 | 113 |
| 12.05 | 36,643 | 18,643 (51 %) | 1,066 | 643 (60 %) |
| 13.05 | 15,265 | 15,265 (100 %)| 903 | 903 (100 %) |
| 14.05 | 2,335 | 2,335 (100 %) | 748 | 748 (100 %) |
| 15.05 | 1,440 | 1,440 (100 %) | 521 | 521 (100 %) |
| 16.05 | 106 | 106 (100 %) | 95 | 95 (100 %) |
| 17.05 | 37 | 37 (100 %) | 10 | 10 (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):

| Date | cost.usage with qsrc | cost.usage empty | sample values when populated |
|-------|---------------------:|-----------------:|--------------------------------|
| 09.05 | 36 | 0 | ['main', 'subagent'] |
| 10.05 | 119 | 0 | ['main', 'subagent', 'auxiliary'] |
| 11.05 | 1,237 | 112 | ['main', 'subagent', 'auxiliary'] |
| 12.05 | 2,182 | 1,939 | ['main', 'subagent', 'auxiliary'] |
| 13.05 | 0 | 2,645 | [] |
| 14.05 | 0 | 1,043 | [] |
| 15.05 | 0 | 853 | [] |
| 16.05 | 0 | 122 | [] |
| 17.05 | 0 | 37 | [] |

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
  1. 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

View original on GitHub ↗

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