Skip to main content

SessionMetrics

Struct SessionMetrics 

Source
pub struct SessionMetrics {
Show 16 fields pub jsonl_save: TimingCounter, pub jsonl_serialize: TimingCounter, pub jsonl_io: TimingCounter, pub jsonl_bytes: ByteCounter, pub jsonl_queue_wait: TimingCounter, pub sqlite_save: TimingCounter, pub sqlite_append: TimingCounter, pub sqlite_serialize: TimingCounter, pub sqlite_bytes: ByteCounter, pub sqlite_load: TimingCounter, pub sqlite_load_meta: TimingCounter, pub index_lock: TimingCounter, pub index_upsert: TimingCounter, pub index_list: TimingCounter, pub index_reindex: TimingCounter, pub append: TimingCounter, /* private fields */
}
Expand description

Centralized session hot-path metrics collector.

Covers four key phases identified in the PERF-3X measurement plan:

  1. Queueing: time between save request and actual IO start
  2. Serialization: serde_json encoding time and output size
  3. IO / Fsync: file write, flush, and atomic-rename time
  4. Index update: session-index upsert time

Plus additional breakdowns for SQLite paths and lock contention.

Fields§

§jsonl_save: TimingCounter

Total wall-clock time for a complete Session::save() JSONL call.

§jsonl_serialize: TimingCounter

Time spent in serde_json::to_writer for header + entries.

§jsonl_io: TimingCounter

Time spent in BufWriter::flush() + tempfile::persist().

§jsonl_bytes: ByteCounter

Bytes written per JSONL save (header + entries).

§jsonl_queue_wait: TimingCounter

Queue wait: time from save() entry to IO thread start.

§sqlite_save: TimingCounter

Total wall-clock time for save_session() (full rewrite).

§sqlite_append: TimingCounter

Total wall-clock time for append_entries() (incremental append).

§sqlite_serialize: TimingCounter

Time spent serializing entries to JSON strings within SQLite save.

§sqlite_bytes: ByteCounter

Total JSON bytes produced during SQLite save serialization.

§sqlite_load: TimingCounter

Total wall-clock time for load_session().

§sqlite_load_meta: TimingCounter

Total wall-clock time for load_session_meta().

§index_lock: TimingCounter

Lock acquisition time in SessionIndex::with_lock().

§index_upsert: TimingCounter

Total wall-clock time for upsert_meta() (including lock).

§index_list: TimingCounter

Total wall-clock time for list_sessions() (including lock).

§index_reindex: TimingCounter

Total wall-clock time for reindex_all().

§append: TimingCounter

Time for Session::append_message() and similar in-memory ops.

Implementations§

Source§

impl SessionMetrics

Source

pub fn enabled(&self) -> bool

Whether metrics collection is active.

Source

pub fn enable(&self)

Explicitly enable metrics (useful for tests).

Source

pub fn disable(&self)

Explicitly disable metrics.

Source

pub fn start_timer<'a>(&'a self, counter: &'a TimingCounter) -> ScopedTimer<'a>

Start a scoped timer for counter. If metrics are disabled, returns a no-op timer that does nothing on drop.

Source

pub fn record_bytes(&self, counter: &ByteCounter, bytes: u64)

Record bytes if metrics are enabled.

Source

pub fn reset_all(&self)

Reset all counters to zero.

Source

pub fn snapshot(&self) -> MetricsSnapshot

Produce a structured snapshot of all metrics.

Source

pub fn summary(&self) -> String

Human-readable multi-line summary for diagnostics.

Source

pub fn emit(&self)

Emit the summary to tracing::debug (called periodically or on demand).

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<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

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> 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: NoopSpan) -> Self

Instruments this future with a span (no-op when disabled).
Source§

fn in_current_span(self) -> Self

Instruments this future with the current span (no-op when disabled).
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
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
Source§

impl<T> ParallelSend for T

Source§

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

Source§

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