pub struct Event {Show 19 fields
pub v: u32,
pub id: String,
pub ts: i64,
pub agent: String,
pub provider: String,
pub model: Option<String>,
pub project: Option<String>,
pub session_id: Option<String>,
pub turn_id: Option<String>,
pub role: String,
pub input_tok: Option<u64>,
pub output_tok: Option<u64>,
pub cache_read_tok: Option<u64>,
pub cache_write_tok: Option<u64>,
pub duration_ms: Option<u64>,
pub stop_reason: Option<String>,
pub cost_est: Option<f64>,
pub tool_calls: Vec<ToolCall>,
pub is_sidechain: Option<bool>,
}Expand description
One normalized event. Unknown fields are tolerated on read so newer stores can be consumed by older binaries.
Fields§
§v: u32Record schema version, per line.
id: StringContent-derived id; identical content always yields the same id.
ts: i64Event time, epoch milliseconds UTC. Decides the month partition.
agent: StringSource agent, e.g. claude-code.
provider: StringModel provider, e.g. anthropic.
model: Option<String>§project: Option<String>§session_id: Option<String>§turn_id: Option<String>§role: Stringassistant, user, …
input_tok: Option<u64>§output_tok: Option<u64>§cache_read_tok: Option<u64>§cache_write_tok: Option<u64>§duration_ms: Option<u64>Unsupported by adapters that do not log it — absent, never 0.
stop_reason: Option<String>§cost_est: Option<f64>Estimated cost; absent when the model has no configured price.
tool_calls: Vec<ToolCall>Nested rather than a separate file, to avoid a join on every scan.
is_sidechain: Option<bool>Whether this event came from a subagent/sidechain transcript.
Implementations§
Source§impl Event
impl Event
Sourcepub fn new(
id: impl Into<String>,
ts: i64,
agent: &str,
provider: &str,
role: &str,
) -> Self
pub fn new( id: impl Into<String>, ts: i64, agent: &str, provider: &str, role: &str, ) -> Self
A minimally populated event at the current record version.
Sourcepub fn total_tokens(&self) -> u64
pub fn total_tokens(&self) -> u64
Whether this record carries usage at all.
Usage is logged once per request and most records legitimately carry none, so “did this cost anything?” is asked on every read path. It is answered here, once: a reader that forgets one of the four fields — cache reads especially, which dominate agentic volume — would quietly classify billable requests as free. Every token this request consumed. Cache reads are the bulk of an agentic loop’s volume, so any figure that excluded them would read far too low; absent counts contribute nothing rather than zero.