pub struct SessionMetrics {Show 30 fields
pub session_id: String,
pub node_id: String,
pub created_at: String,
pub model: String,
pub total_input_tokens: u64,
pub total_output_tokens: u64,
pub total_thinking_tokens: u64,
pub total_thinking_bytes: u64,
pub estimated_cost: f64,
pub total_chars: u64,
pub total_tool_calls: u32,
pub tool_breakdown: HashMap<String, u32>,
pub tool_fail_rate: f64,
pub total_failed: u32,
pub total_duration_ms: u64,
pub total_llm_ms: u64,
pub total_tool_ms: u64,
pub total_turns: u32,
pub avg_turn_ms: u64,
pub p50_turn_ms: u64,
pub p95_turn_ms: u64,
pub p99_turn_ms: u64,
pub outcome: SessionOutcome,
pub error_count: u32,
pub total_plan_updates: u32,
pub total_approvals: u32,
pub custom: Value,
pub parent_session_id: Option<String>,
pub session_type: String,
pub turns: Vec<TurnMetrics>,
}Expand description
Accumulated session metrics. Written incrementally to session_metrics.json
at the end of each turn.
Fields§
§session_id: String§node_id: String§created_at: String§model: String§total_input_tokens: u64§total_output_tokens: u64§total_thinking_tokens: u64§total_thinking_bytes: u64Total byte length of reasoning/thinking content across all turns.
estimated_cost: f64§total_chars: u64§total_tool_calls: u32§tool_breakdown: HashMap<String, u32>§tool_fail_rate: f64§total_failed: u32Running total of failed tool calls.
total_duration_ms: u64§total_llm_ms: u64§total_tool_ms: u64§total_turns: u32§avg_turn_ms: u64§p50_turn_ms: u64§p95_turn_ms: u64§p99_turn_ms: u64§outcome: SessionOutcome§error_count: u32§total_plan_updates: u32§total_approvals: u32§custom: Value§parent_session_id: Option<String>§session_type: String§turns: Vec<TurnMetrics>Implementations§
Source§impl SessionMetrics
impl SessionMetrics
Sourcepub fn new(session_id: String, node_id: String, model: String) -> SessionMetrics
pub fn new(session_id: String, node_id: String, model: String) -> SessionMetrics
Create a new session metrics accumulator (empty turns).
Sourcepub fn append_turn(&mut self, turn: TurnMetrics)
pub fn append_turn(&mut self, turn: TurnMetrics)
Append a turn and recompute session-level aggregates.
Sourcepub fn finalize(&mut self, outcome: SessionOutcome)
pub fn finalize(&mut self, outcome: SessionOutcome)
Finalize the session — recompute percentiles and set outcome.
Sourcepub fn merge_turns(&mut self, other: &SessionMetrics)
pub fn merge_turns(&mut self, other: &SessionMetrics)
Merge another accumulator’s per-turn records into this one and rebuild every session-level aggregate from the merged list.
Turns are deduplicated on (turn_number, started_at), so the union is
idempotent: re-saving the same turns from the same process changes
nothing, while turns recorded by another writer over the same session
(a TUI session switch, a new process resuming it) are folded in instead
of clobbering the history. Identity/custom fields and outcome keep
self’s values — the caller decides whose identity and final state win.
Trait Implementations§
Source§impl Clone for SessionMetrics
impl Clone for SessionMetrics
Source§fn clone(&self) -> SessionMetrics
fn clone(&self) -> SessionMetrics
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more