Skip to main content

AnalyticsStore

Struct AnalyticsStore 

Source
pub struct AnalyticsStore {
    pub workspace_label_mode: WorkspaceLabelMode,
    /* private fields */
}

Fields§

§workspace_label_mode: WorkspaceLabelMode

Implementations§

Source§

impl AnalyticsStore

Source

pub fn export_jsonl(&self, output: &mut dyn Write) -> Result<u64>

Streams every turn, tool-call, and token-usage row as normalized JSONL into output. Returns the record count.

Source§

impl AnalyticsStore

Source

pub fn tool_summaries(&self, filter: &StatsFilter) -> Result<Vec<ToolSummary>>

Per-tool summaries with exact percentiles computed from raw durations in the filtered window.

Source

pub fn token_summaries( &self, group: TokenGroup, filter: &StatsFilter, ) -> Result<Vec<TokenSummaryRow>>

Token summaries grouped by day, session, provider, model, or workspace. Reads only the projected tables, never raw JSONL.

Source

pub fn session_summaries( &self, filter: &StatsFilter, ) -> Result<Vec<SessionSummary>>

Session summaries sortable by tokens, tool calls, duration, errors.

Source

pub fn usage_summary(&self, filter: &StatsFilter) -> Result<UsageSummary>

Overall window summary for dashboards and stats summary.

Source

pub fn never_used_tools( &self, registered: &[String], filter: &StatsFilter, ) -> Result<Vec<String>>

Registered tools that were never called in the window.

Source§

impl AnalyticsStore

Source

pub fn refresh_daily_rollups(&self) -> Result<u64>

Recomputes all daily rollups from raw rows. Deterministic and idempotent: the rollup table always reflects the raw tables.

Source

pub fn daily_rollups(&self) -> Result<Vec<DailyRollupRow>>

Source§

impl AnalyticsStore

Source

pub fn open( path: &Path, workspace_label_mode: WorkspaceLabelMode, ) -> Result<Self>

Opens (creating directories and schema as needed) the analytics database at path.

Source

pub fn default_path(data_dir: &Path) -> PathBuf

Default location under a Roder data directory.

Source

pub fn path(&self) -> &Path

Source

pub fn upsert_session(&self, record: &SessionRecord) -> Result<()>

Upserts session metadata. Later non-null values win; created_at_ms keeps the earliest observed value.

Source

pub fn upsert_turn(&self, record: &TurnRecord) -> Result<()>

Upserts a turn keyed by (thread_id, turn_id). Terminal statuses (completed/failed) are never downgraded back to running.

Source

pub fn upsert_token_usage(&self, record: &TokenUsageRecord) -> Result<()>

Upserts terminal token usage for a turn keyed by (thread_id, turn_id); replaying the same terminal event is a no-op rather than a double count.

Source

pub fn upsert_tool_call(&self, record: &ToolCallRecord) -> Result<()>

Upserts a tool call keyed by (thread_id, turn_id, tool_id), merging start/completion halves into one logical record.

Source

pub fn import_offset(&self, source_path: &str) -> Result<Option<u64>>

Source

pub fn record_import_offset( &self, source_path: &str, last_line: u64, source_mtime_ms: Option<i64>, ) -> Result<()>

Source

pub fn clear_all(&self) -> Result<()>

Clears all analytics rows (used by --rebuild before replaying JSONL). The schema and migrations are kept.

Source

pub fn apply_retention(&self, retention_days: u32) -> Result<u64>

Deletes raw rows older than retention_days (sessions are kept while any of their activity remains). Returns the number of deleted rows. 0 days disables pruning. Rollups are not touched here; callers refresh them after pruning.

Source

pub fn counts(&self) -> Result<StoreCounts>

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