
OCDevel Claude Code · July 3
Fleet observability for parallel Claude Code: built-in OpenTelemetry, Grafana cost dashboards, and per-agent spend attribution
0:00Duration unknown
transcript
show notes
Wire every parallel Claude Code session, subagent, and headless run into one OpenTelemetry feed and watch per-agent token burn and dollar cost on a Grafana dashboard, with stall detection that catches a looping agent before it drains the budget. The one trap: the same opt-in log flags that give you attribution can ship raw prompts and pasted credentials to your observability backend, and one shared API key collapses every worktree's cost into a single lying bucket.
This week's Claude Code releases, then a full tutorial on fleet observability and cost dashboards for parallel runs.
News (2026-06-26 to 2026-07-03, from the Claude Code changelog):
- Claude Sonnet 5 is now the default (v2.1.197, Jun 30): native 1M-token context, promo pricing
$2/$10per Mtok through Aug 31. Shows in/model. (Some trackers misdate it to Jul 1 - the docs changelog is authoritative.) - Background subagents by default (v2.1.198, Jul 1): agents keep running and notify on finish;
claude agentsruns now commit, push, and open a draft PR from a worktree;Notificationhook firesagent_needs_input/agent_completed; Explore agent inherits the session model (capped at opus); new/datavizskill; the/agentswizard was removed. - Stacked skills + retry controls (v2.1.199, Jul 2):
/skill-a /skill-bloads up to 5;CLAUDE_CODE_RETRY_WATCHDOGraises retries to 300; fixed subagents reporting usage-limit errors as success, plus a Linux daemon that killed all agents every ~50s. - Org defaults + durability (v2.1.196, Jun 29): admin org default model, stream idle watchdog on by default, background sessions survive restarts.
Tutorial - Fleet observability and cost dashboards:
- Native OpenTelemetry, opt-in via
CLAUDE_CODE_ENABLE_TELEMETRY=1- Monitoring docs. Metrics likeclaude_code.cost.usage,claude_code.token.usage,claude_code.active_time.total; log events; beta trace spans (claude_code.interactionroot). - Reference stack: ColeMurray/claude-code-otel (Collector to Prometheus + Loki to Grafana, six-section dashboard).
- Cost tools:
/costslash command (Manage costs); ccusage (npx ccusage@latest,ccusage blocks --live); org-level Usage and Cost API and the per-user Claude Code Analytics API. - Headless mode:
claude -p --output-format jsonreturnstotal_cost_usd,num_turns,session_id; guard with--max-turnsand--max-budget-usd. - AWS worked example: Analyzing Claude Code usage with CloudWatch and OpenTelemetry.
- Pitfall:
OTEL_LOG_USER_PROMPTS=1/OTEL_LOG_TOOL_DETAILS=1leak prompt text and credentials (Elastic Security Labs); one shared API key breaks per-worktree attribution.
links12