Skip to main content

TelemetryEvent

Struct TelemetryEvent 

Source
pub struct TelemetryEvent {
    pub event_id: Uuid,
    pub session_id: String,
    pub turn_no: u32,
    pub turn_id: Option<String>,
    pub timestamp_ms: i64,
    pub schema_version: u32,
    pub payload: EventPayload,
}
Expand description

一个遥测事件(转成 JSON 时展平 event_id/session_id/timestamp 在顶层)。

Fields§

§event_id: Uuid

UUID v4,client 生成。

§session_id: String

关联 session。

§turn_no: u32

当前 turn 编号(从 0 计)。

§turn_id: Option<String>

关联 turn 的 ID。None = 会话级事件(无 turn 关联)。

§timestamp_ms: i64

Client 本地 Unix 毫秒。

§schema_version: u32§payload: EventPayload

事件体。

Implementations§

Source§

impl TelemetryEvent

Source

pub fn session_start( session_id: &str, turn_no: u32, turn_id: Option<String>, p: SessionStartPayload, ) -> TelemetryEvent

daemon 建好一个会话之后、它的第一轮之前;新建与按 id 重建都算。

Source

pub fn session_end( session_id: &str, turn_no: u32, turn_id: Option<String>, p: SessionEndPayload, ) -> TelemetryEvent

会话的主循环退出(关闭、输入通道关闭、被取消);合计是这次载入以来的。

Source

pub fn startup_timing( session_id: &str, turn_no: u32, turn_id: Option<String>, p: StartupTimingPayload, ) -> TelemetryEvent

daemon 启动完成、开始接请求时,一次。

Source

pub fn api_request( session_id: &str, turn_no: u32, turn_id: Option<String>, p: ApiRequestPayload, ) -> TelemetryEvent

每次模型调用完成。一轮里的调用不带 purpose;辅助调用带:compact、memory、title、hook、team_judge、web_search、web_fetch。

Source

pub fn api_error( session_id: &str, turn_no: u32, turn_id: Option<String>, p: ApiErrorPayload, ) -> TelemetryEvent

一轮里的一次模型调用失败:请求被拒,或流在回复完整之前断了。每次失败的尝试一条,不论这一轮后来恢复没有;取消不算。

Source

pub fn provider_switched( session_id: &str, turn_no: u32, turn_id: Option<String>, p: ProviderSwitchedPayload, ) -> TelemetryEvent

一次模型调用去了与本会话上一次调用不同的 provider:排在前面的配额用完、没有密钥、密钥被拒、连不上或重试用尽,或排在前面的又能用了。

Source

pub fn tool_start( session_id: &str, turn_no: u32, turn_id: Option<String>, p: ToolStartPayload, ) -> TelemetryEvent

工具开始执行:PreToolUse hook、输入校验、权限都放行之后。

Source

pub fn tool_execution( session_id: &str, turn_no: u32, turn_id: Option<String>, p: ToolExecutionPayload, ) -> TelemetryEvent

工具执行结束,成功或失败;工具自己报告的失败(如 Bash 非零退出)算失败。

Source

pub fn tool_cancelled( session_id: &str, turn_no: u32, turn_id: Option<String>, p: ToolCancelledPayload, ) -> TelemetryEvent

一次工具调用在等权限回答时会话被关闭。

Source

pub fn permission_decision( session_id: &str, turn_no: u32, turn_id: Option<String>, p: PermissionDecisionPayload, ) -> TelemetryEvent

会话的权限检查对一次工具调用作出判定,在询问任何人之前。

Source

pub fn user_prompt_submit( session_id: &str, turn_no: u32, turn_id: Option<String>, p: UserPromptSubmitPayload, ) -> TelemetryEvent

一轮开始,紧接 turn_start:开这一轮的用户消息,只记大小。

Source

pub fn slash_command_used( session_id: &str, turn_no: u32, turn_id: Option<String>, p: SlashCommandUsedPayload, ) -> TelemetryEvent

开一轮的消息是斜杠命令。

Source

pub fn turn_start( session_id: &str, turn_no: u32, turn_id: Option<String>, p: TurnStartPayload, ) -> TelemetryEvent

一轮开始,UserPromptSubmit hook 放行之后。

Source

pub fn turn_complete( session_id: &str, turn_no: u32, turn_id: Option<String>, p: TurnCompletePayload, ) -> TelemetryEvent

一轮结束,stop_reason 说怎么结束的。

Source

pub fn budget_enforced( session_id: &str, turn_no: u32, turn_id: Option<String>, p: BudgetEnforcedPayload, ) -> TelemetryEvent

会话 token 预算到 90% 注入收尾提醒,或到 100% 中止这一轮。

Source

pub fn compact_action( session_id: &str, turn_no: u32, turn_id: Option<String>, p: CompactActionPayload, ) -> TelemetryEvent

一次压缩完成或失败,或一次修剪(kind 为 trim:只清旧工具结果,不改写历史)。

Source

pub fn hook_run( session_id: &str, turn_no: u32, turn_id: Option<String>, p: HookRunPayload, ) -> TelemetryEvent

一个事件的 hooks 跑完一次;没配 hook 的事件不记。turn_no 恒为 0,按 turn_id 关联。

Source

pub fn resume_action( session_id: &str, turn_no: u32, turn_id: Option<String>, p: ResumeActionPayload, ) -> TelemetryEvent

会话从日志重建(会话文件);恢复请求落到已在内存里、找不到、已结束的侧链会话上(池文件);团队从 scratchpad 接上(会话文件)。

Source

pub fn mcp_server_connected( session_id: &str, turn_no: u32, turn_id: Option<String>, p: McpServerConnectedPayload, ) -> TelemetryEvent

一个 MCP server 连上:启动时、重载时、新增时。

Source

pub fn mcp_connection_error( session_id: &str, turn_no: u32, turn_id: Option<String>, p: McpConnectionErrorPayload, ) -> TelemetryEvent

一个要连的 MCP server 没连上:起不来、握手失败或超时、配置被拒。

Source

pub fn agent_spawned( session_id: &str, turn_no: u32, turn_id: Option<String>, p: AgentSpawnedPayload, ) -> TelemetryEvent

子 Agent 开始:Agent 工具起的(前台、后台)、常驻团队成员、TeamCreate 流水线的成员。

Source

pub fn agent_completed( session_id: &str, turn_no: u32, turn_id: Option<String>, p: AgentCompletedPayload, ) -> TelemetryEvent

子 Agent 结束;常驻团队成员在被停下时。

Source

pub fn team_stage_complete( session_id: &str, turn_no: u32, turn_id: Option<String>, p: TeamStageCompletePayload, ) -> TelemetryEvent

TeamCreate 流水线的一个阶段跑完。

Source§

impl TelemetryEvent

Source

pub fn kind(&self) -> &'static str

事件类型的稳定标识(等同序列化后的 type 字段),用于按点过滤配置。

Trait Implementations§

Source§

impl Clone for TelemetryEvent

Source§

fn clone(&self) -> TelemetryEvent

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TelemetryEvent

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Redact for TelemetryEvent

Source§

fn redact(self, policy: &RedactionPolicy) -> Self

Source§

impl Serialize for TelemetryEvent

Source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more