Skip to main content

Event

Struct Event 

Source
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: u32

Record schema version, per line.

§id: String

Content-derived id; identical content always yields the same id.

§ts: i64

Event time, epoch milliseconds UTC. Decides the month partition.

§agent: String

Source agent, e.g. claude-code.

§provider: String

Model provider, e.g. anthropic.

§model: Option<String>§project: Option<String>§session_id: Option<String>§turn_id: Option<String>§role: String

assistant, 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

Source

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.

Source

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.

Source

pub fn has_usage(&self) -> bool

Trait Implementations§

Source§

impl Clone for Event

Source§

fn clone(&self) -> Event

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 Event

Source§

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

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

impl<'de> Deserialize<'de> for Event

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for Event

Source§

fn eq(&self, other: &Event) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for Event

Source§

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

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Event

Auto Trait Implementations§

§

impl Freeze for Event

§

impl RefUnwindSafe for Event

§

impl Send for Event

§

impl Sync for Event

§

impl Unpin for Event

§

impl UnsafeUnpin for Event

§

impl UnwindSafe for Event

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.