Skip to main content

Crate telemetry

Crate telemetry 

Source
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 telemetry block.
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_path is 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§

AgentCompletedPayload
A sub-agent finished.
AgentSpawnedPayload
A sub-agent started: one the Agent tool runs, or a team member.
ApiErrorPayload
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.
ApiRequestPayload
One completed model call: what it cost and what it was.
BudgetEnforcedPayload
会话 token 预算强制执行事件的载荷——turn.token_budget 90% 提醒注入 或 100% 硬停两种动作都用这个 payload,用 action 区分。
CompactActionPayload
压缩行为事件的载荷。
HookRunPayload
One run of an event’s hooks: how long the model’s step waited on them, and whether they stopped something.
McpConnectionErrorPayload
An MCP server that was to be connected was not: it would not start, the handshake failed or timed out, its configuration was rejected.
McpServerConnectedPayload
An MCP server connected: at startup, on a reload, or when one is added.
PermissionDecisionPayload
What became of one tool call’s permission: the conclusion, after whoever could answer the session’s question did.
ProviderSwitchedPayload
A model call that went to a different provider than the session’s call before it.
ResumeActionPayload
Resume / replay 结果。Payload 只记录结构化类别和计数,不包含 transcript 内容。
SessionEndPayload
Session 结束事件的载荷。
SessionStartPayload
Session 开始事件的载荷。
SlashCommandUsedPayload
A turn whose message is a slash command.
StartupTimingPayload
How long the daemon took to start, recorded once it is ready to serve.
TeamStageCompletePayload
Team 流水线阶段完成事件的载荷。
TelemetryEvent
一个遥测事件(转成 JSON 时展平 event_id/session_id/timestamp 在顶层)。
ToolCancelledPayload
工具被取消事件的载荷。
ToolExecutionPayload
工具执行事件的载荷。
ToolStartPayload
工具开始执行事件的载荷(在 ToolExecution 之前发出)。
TurnCompletePayload
单轮完成事件的载荷。
TurnStartPayload
单轮开始事件的载荷。
UserPromptSubmitPayload
The message a user turn opens with — its size, never its text.

Enums§

BudgetEnforcedAction
CompactKind
改写历史的压缩,还是只清旧工具结果的修剪。
EventPayload
事件体枚举 —— 每种变体序列化为 type discriminator + 字段。
PermissionDecisionOutcome
ResumeOutcome
ToolOutcome