pub struct AnalyticsStore {
pub workspace_label_mode: WorkspaceLabelMode,
/* private fields */
}Fields§
§workspace_label_mode: WorkspaceLabelModeImplementations§
Source§impl AnalyticsStore
impl AnalyticsStore
Sourcepub fn export_jsonl(&self, output: &mut dyn Write) -> Result<u64>
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
impl AnalyticsStore
Sourcepub fn tool_summaries(&self, filter: &StatsFilter) -> Result<Vec<ToolSummary>>
pub fn tool_summaries(&self, filter: &StatsFilter) -> Result<Vec<ToolSummary>>
Per-tool summaries with exact percentiles computed from raw durations in the filtered window.
Sourcepub fn token_summaries(
&self,
group: TokenGroup,
filter: &StatsFilter,
) -> Result<Vec<TokenSummaryRow>>
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.
Sourcepub fn session_summaries(
&self,
filter: &StatsFilter,
) -> Result<Vec<SessionSummary>>
pub fn session_summaries( &self, filter: &StatsFilter, ) -> Result<Vec<SessionSummary>>
Session summaries sortable by tokens, tool calls, duration, errors.
Sourcepub fn usage_summary(&self, filter: &StatsFilter) -> Result<UsageSummary>
pub fn usage_summary(&self, filter: &StatsFilter) -> Result<UsageSummary>
Overall window summary for dashboards and stats summary.
Sourcepub fn never_used_tools(
&self,
registered: &[String],
filter: &StatsFilter,
) -> Result<Vec<String>>
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
impl AnalyticsStore
Sourcepub fn refresh_daily_rollups(&self) -> Result<u64>
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.
pub fn daily_rollups(&self) -> Result<Vec<DailyRollupRow>>
Source§impl AnalyticsStore
impl AnalyticsStore
Sourcepub fn open(
path: &Path,
workspace_label_mode: WorkspaceLabelMode,
) -> Result<Self>
pub fn open( path: &Path, workspace_label_mode: WorkspaceLabelMode, ) -> Result<Self>
Opens (creating directories and schema as needed) the analytics
database at path.
Sourcepub fn default_path(data_dir: &Path) -> PathBuf
pub fn default_path(data_dir: &Path) -> PathBuf
Default location under a Roder data directory.
pub fn path(&self) -> &Path
Sourcepub fn upsert_session(&self, record: &SessionRecord) -> Result<()>
pub fn upsert_session(&self, record: &SessionRecord) -> Result<()>
Upserts session metadata. Later non-null values win; created_at_ms
keeps the earliest observed value.
Sourcepub fn upsert_turn(&self, record: &TurnRecord) -> Result<()>
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.
Sourcepub fn upsert_token_usage(&self, record: &TokenUsageRecord) -> Result<()>
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.
Sourcepub fn upsert_tool_call(&self, record: &ToolCallRecord) -> Result<()>
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.
pub fn import_offset(&self, source_path: &str) -> Result<Option<u64>>
pub fn record_import_offset( &self, source_path: &str, last_line: u64, source_mtime_ms: Option<i64>, ) -> Result<()>
Sourcepub fn clear_all(&self) -> Result<()>
pub fn clear_all(&self) -> Result<()>
Clears all analytics rows (used by --rebuild before replaying
JSONL). The schema and migrations are kept.
Sourcepub fn apply_retention(&self, retention_days: u32) -> Result<u64>
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.