Claude adds OpenTelemetry observability for Claude Code and subagents
Detailed traces are gated behind a Beta flag, so teams that want full subagent call chains need to opt in explicitly. The setup works with Grafana or a local receiver, and subscription-logged Claude Code users can use it too — no API key required. Engineering teams running long agent workflows in production get billing and latency attribution they previously had to reconstruct manually.
Claude now supports OpenTelemetry-based observability for Claude Code and its subagents. Users can track token usage by input, output, and cache reads/writes, broken down by main agent versus subagents, with estimated costs. Timing metrics cover each task turn, model request, and time to first token, distinguishing slow tool execution from waiting on user confirmation. Tool calls, errors, and model request retries are logged, with subagents nested under their parent agent's trace. API users enable it in Console's OpenTelemetry settings, while Claude Code users turn on telemetry in the env section of user-level settings.json; detailed traces require a Beta option, and the Agent SDK reuses the same configuration.
Claude 支持 o11y 了,Claude Code 和子 Agent 也能监控。
以后可以通过各种监控平台看到:
token 花在哪:输入、输出、缓存读写各用了多少,主 Agent、子 Agent 分别消耗多少,还能查看估算费用。
时间耗在哪:每轮任务、每次模型请求、等待首个 token 各花多久;工具执行慢,还是一直在等你点确认,也能分开。
谁在出问题:调用了什么工具、是否成功、哪里报错、模型请求尝试了几次。子 Agent 会挂在父 Agent 的调用链下面,可以逐个展开查。
看着任务转圈、额度往下掉,至少有记录可查,不用一直猜它在忙什么。
接入有两条路径:API 用户在 Console 的 OpenTelemetry 设置里添加监控平台; Claude Code 用户在用户级 settings.json 的 env 中开启遥测、配置导出器和接收地址,重启后开始采集。详细调用链还要开启 Beta 选项,Agent SDK 可以沿用同一套配置。
可以接 Grafana 等监控平台,也可以部署在本机,把监控记录留在电脑上。订阅登录的 Claude Code 同样能用。
如果用户或企业需要,我们的Tokei 也可以做这些,我后面想个计划🤔 https://t.co/Q3ab0tB9fa
- TestingCatalog10-14 20:58原文