pub struct SessionStats { /* private fields */ }Expand description
SessionStatsRecorder: counts in memory and saves the document shortly after a change.
Implementations§
Source§impl SessionStats
impl SessionStats
Sourcepub fn set_root(&self, root: &str)
pub fn set_root(&self, root: &str)
Count this session as one whose root is root (external for Claude Code). Called before
SessionStats::attach, it is the root the stored document takes; nothing is saved until a counter changes.
Source§impl SessionStats
impl SessionStats
Sourcepub fn new(root: &str, now: Clock, flush_after: Duration) -> SessionStats
pub fn new(root: &str, now: Clock, flush_after: Duration) -> SessionStats
A recorder for a session whose root is root (lane, or external for Claude Code over MCP), counting
from now(); it saves to nothing until SessionStats::attach gives it its store.
Sourcepub fn system(root: &str) -> SessionStats
pub fn system(root: &str) -> SessionStats
A recorder on the system clock that saves 500 ms after a change.
Sourcepub fn attach(&self, store: Arc<dyn StatsStore>)
pub fn attach(&self, store: Arc<dyn StatsStore>)
Read the stored counters from store and keep counting on top of them (#load); changes made before are
applied to what was stored. The session keeps the kind of root it has now.
Sourcepub fn touch(&self)
pub fn touch(&self)
Something ran in the session: its counters are saved even while they are all zero.
Sourcepub fn cell(&self, lane: &str, code: &str, failed: bool, masked: usize)
pub fn cell(&self, lane: &str, code: &str, failed: bool, masked: usize)
One cell ran on lane: whether it failed, and how many secrets were masked in its output.
Sourcepub fn guard(&self, record: &GuardOutcome<'_>)
pub fn guard(&self, record: &GuardOutcome<'_>)
One guard outcome (Loki, extensions).
Sourcepub fn nudge(&self, message: &str)
pub fn nudge(&self, message: &str)
A steer sent to the root; text that is not one of the known steers is not counted.
Sourcepub fn usage_limit_block(&self)
pub fn usage_limit_block(&self)
A tool call, model request or admission refused because a root’s limit was hit.
Sourcepub fn child_model(&self, task_id: &str, model: &str)
pub fn child_model(&self, task_id: &str, model: &str)
The model an rlm.spawn subagent ran on.
Sourcepub fn external_turn_started(&self, turn: &str)
pub fn external_turn_started(&self, turn: &str)
A turn of an external root began (Claude Code’s UserPromptSubmit, or its first cell).