遥测事件与指标参考
选择工具、API、Goal 和 daemon 指标,并避免重复累计和状态误读。
日志记录具体事件,指标聚合数值。事件名和属性并非完全统一命名,查询时应使用实际名称;多数指标以 qwen-code. 开头。
按问题选择事件
| 问题 | 主要事件 |
|---|---|
| 启动与会话切换 | qwen-code.config、session.start、session.end |
| 用户输入与重试 | qwen-code.user_prompt、qwen-code.user_retry |
| 工具结果与文件操作 | qwen-code.tool_call、qwen-code.file_operation、qwen-code.tool_output_truncated |
| 模型 API | qwen-code.api_request、api_response、api_error、api_cancel、api_retry,后三者同样带 qwen-code. 前缀 |
| 内容流重试 | qwen-code.chat.content_retry、content_retry_failure、invalid_chunk,后两者带 qwen-code.chat. 前缀 |
| 扩展与命令 | qwen-code.slash_command、qwen-code.skill_launch、qwen-code.extension_install 等 |
| 委派与工作流 | qwen-code.subagent_execution、qwen-code.workflow_run、qwen-code.workflow_size_warning |
| Goal、Arena、自动记忆 | qwen-code.goal_state、qwen-code.arena_session_ended、qwen-code.memory.extract/dream/recall |
| 建议与推测执行 | qwen-code.prompt_suggestion、qwen-code.speculation |
loop_detected 与 kitty_sequence_overflow 是保留的无 qwen-code. 前缀事件。tool_output_truncated 已改为 qwen-code.tool_output_truncated,旧查询需要更新。
工具状态的两种含义
qwen-code.tool_call 的 status 是终态 success/error/cancelled。execution_status 则说明是否执行以及执行结果,可为 not_started、success、error、cancelled、unknown;缺失时规范化为 unknown,不能从外层终态推断。
error 终态始终提供非空 error_type,无法分类则为 unknown;success/cancelled 省略错误字段。空工具名规范化为 unknown_tool。
| 指标 | 维度与解释 |
|---|---|
| qwen-code.tool.call.count | function_name、status、兼容 success、可选 decision/tool_type |
| qwen-code.tool.execution.count | execution_status、tool_type;故意不带 function_name |
| qwen-code.tool.call.latency | 只有 function_name,不带 decision |
| qwen-code.file.operation.count | operation 与文件类型等,不含 diff-stat |
计算执行失败比例时,用 error / (success + error),排除 unknown、not_started、cancelled。需要按具体工具归因时查 tool_call 日志;文件增加/删除行字符数在该事件 metadata 中,不在 file_operation 或对应指标里。
API 与重试
api.request.count/latency、token.usage、api.request.breakdown 均带 qwen-code. 前缀,分别反映请求、耗时、token 和阶段耗时。token type 包括 input、output、thought、cache,不能不加区分地相加为计费用量。
qwen-code.api_retry 表示 HTTP 状态触发的重试,与内容流 InvalidStreamError 的独立重试预算不同。其 duration_ms 等于退避等待 retry_delay_ms,不是 HTTP 往返;单次调用耗时应看 llm_request span。
Goal 与工作流统计
goal_state 只记录文档指定的状态转换,不为每个 turn_finished/checkpoint 或恢复出的旧状态发事件。事件本身不含 objective、stop reason、checkpoint failure 文本,但工具调用 function_args 仍可能包含目标与模型理由。
goal.tokens_used 与 goal.turn_count 直方图只在 complete、blocked、usage_limited 停止时观察累计值;同一 Goal 恢复后可被多次观察。因此 _count 是停止次数,_sum 不能当作不同 Goal 的总消耗。旧记录恢复的 0 也不能证明历史消耗为零。
workflow_run 的 agents_completed 表示所有已结束的 dispatch;agents_failed、agents_cached 是它的子集。agents_respawned 描述重新执行来源,不是一个可额外相加的互斥结局数。workflow_size_warning 每次 run 最多一次,axis 记录首先超过的阈值。
daemon 运行指标
| 指标,均带 qwen-code. 前缀 | 用途 |
|---|---|
| daemon.http.request.count / duration | 按 route/status_class 计数与 route 耗时 |
| daemon.session.active / lifecycle | 活动会话与 spawn/close/die |
| daemon.channel.lifecycle | ACP channel spawn/exit |
| daemon.prompt.queue_wait / duration | FIFO 等待与端到端 prompt 耗时 |
| daemon.bridge.error.count / daemon.cancel.count | bridge 错误与取消请求 |
| daemon.sse.active / daemon.process.heap_used | 活动 SSE 与 heap bytes |
三个 ObservableGauge 在采集时回调更新,daemon 初始化需注册 registerDaemonGaugeCallbacks。资源监控另有 qwen-code.memory.usage 的 heap_used/rss 和 qwen-code.cpu.usage。
startup.duration、tool.queue.depth、tool.execution.breakdown、token.efficiency、performance.score 及 performance.regression/baseline 系列虽有定义,文档标为尚未在生产启用的保留项。缺少这些值不应直接诊断为 exporter 故障。