Expand description
Telemetry — structured event recording with pluggable, callback-based export.
This crate never talks to the network itself: it only defines the event
schema, applies per-event-kind filtering and redaction, and hands
surviving events to whatever TelemetryRecorder callbacks the caller
passes to [spawn]. Where events actually end up (a file, an HTTP
endpoint, an OTLP collector, …) is entirely the caller’s decision — see
daemon::telemetry_otel for the OTLP recorder this workspace ships.
Default: noop (zero overhead) when disabled or given no recorders. Events are dropped silently if the channel is full — telemetry never blocks the agent.
Re-exports§
pub use config::TelemetryConfig;pub use config::TelemetryMode;pub use file_recorder::FileRecorder;pub use handle::EventFilter;pub use handle::NoopHandle;pub use handle::TelemetryHandle;pub use handle::TelemetryHandleError;pub use handle::TelemetryRecorder;pub use redact::Redact;pub use redact::RedactionPolicy;pub use spawn::spawn;pub use spawn::SpawnError;pub use spawn::TelemetryConsumer;
Modules§
- config
- Telemetry configuration — deserialized from settings.json
telemetryblock. - events
- The event schema lives in
base::telemetry; this module keeps the old path. - file_
recorder - FileRecorder — appends telemetry events as JSONL to a file.
- handle
TelemetryHandle— 插桩侧持有的 channel sender。- perf
- Perf — in-process lightweight performance metrics collector. Always running. Non-blocking. No external dependencies.
- recorder
- Recorder — records every LLM call and replays it deterministically.
- redact
- Redaction policy: what is replaced before telemetry events leave the
process. Error messages are the only free text an event carries, so the
policy is a single switch;
sanitize_pathis the helper for callers that keep a path but not the username in it. - spawn
- Spawn telemetry pipeline — returns a handle and a background consumer future.
Structs§
- Agent
Completed Payload - A sub-agent finished.
- Agent
Spawned Payload - A sub-agent started: one the
Agenttool runs, or a team member. - ApiError
Payload - A model call that failed: the provider refused it, or its stream broke before the reply was complete. Emitted once per failed attempt, whether or not the turn then recovers.
- ApiRequest
Payload - One completed model call: what it cost and what it was.
- Budget
Enforced Payload - 会话 token 预算强制执行事件的载荷——
turn.token_budget90% 提醒注入 或 100% 硬停两种动作都用这个 payload,用action区分。 - Compact
Action Payload - 压缩行为事件的载荷。
- Hook
RunPayload - One run of an event’s hooks: how long the model’s step waited on them, and whether they stopped something.
- McpConnection
Error Payload - An MCP server that was to be connected was not: it would not start, the handshake failed or timed out, its configuration was rejected.
- McpServer
Connected Payload - An MCP server connected: at startup, on a reload, or when one is added.
- Permission
Decision Payload - What became of one tool call’s permission: the conclusion, after whoever could answer the session’s question did.
- Provider
Switched Payload - A model call that went to a different provider than the session’s call before it.
- Resume
Action Payload - Resume / replay 结果。Payload 只记录结构化类别和计数,不包含 transcript 内容。
- Session
EndPayload - Session 结束事件的载荷。
- Session
Start Payload - Session 开始事件的载荷。
- Slash
Command Used Payload - A turn whose message is a slash command.
- Startup
Timing Payload - How long the daemon took to start, recorded once it is ready to serve.
- Team
Stage Complete Payload - Team 流水线阶段完成事件的载荷。
- Telemetry
Event - 一个遥测事件(转成 JSON 时展平
event_id/session_id/timestamp在顶层)。 - Tool
Cancelled Payload - 工具被取消事件的载荷。
- Tool
Execution Payload - 工具执行事件的载荷。
- Tool
Start Payload - 工具开始执行事件的载荷(在 ToolExecution 之前发出)。
- Turn
Complete Payload - 单轮完成事件的载荷。
- Turn
Start Payload - 单轮开始事件的载荷。
- User
Prompt Submit Payload - The message a user turn opens with — its size, never its text.
Enums§
- Budget
Enforced Action - Compact
Kind - 改写历史的压缩,还是只清旧工具结果的修剪。
- Event
Payload - 事件体枚举 —— 每种变体序列化为
typediscriminator + 字段。 - Permission
Decision Outcome - Resume
Outcome - Tool
Outcome