Skip to main content

StorageBackend

Trait StorageBackend 

Source
pub trait StorageBackend: Send + Sync {
Show 32 methods // Required methods fn initialize<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>> where 'life0: 'async_trait, Self: 'async_trait; fn write_log<'life0, 'life1, 'async_trait>( &'life0 self, log: &'life1 LogRecord, ) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>> where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait; fn write_span<'life0, 'life1, 'async_trait>( &'life0 self, span: &'life1 Span, ) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>> where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait; fn write_metric<'life0, 'life1, 'async_trait>( &'life0 self, metric: &'life1 Metric, ) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>> where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait; fn query_logs<'life0, 'life1, 'async_trait>( &'life0 self, params: &'life1 QueryParams, ) -> Pin<Box<dyn Future<Output = Result<Vec<LogRecord>, StorageError>> + Send + 'async_trait>> where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait; fn query_spans<'life0, 'life1, 'async_trait>( &'life0 self, params: &'life1 QueryParams, ) -> Pin<Box<dyn Future<Output = Result<Vec<Span>, StorageError>> + Send + 'async_trait>> where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait; fn query_spans_for_trace_list<'life0, 'life1, 'async_trait>( &'life0 self, params: &'life1 QueryParams, trace_limit: usize, ) -> Pin<Box<dyn Future<Output = Result<Vec<Span>, StorageError>> + Send + 'async_trait>> where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait; fn query_metrics<'life0, 'life1, 'async_trait>( &'life0 self, params: &'life1 QueryParams, ) -> Pin<Box<dyn Future<Output = Result<Vec<Metric>, StorageError>> + Send + 'async_trait>> where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait; fn query_latest_metrics<'life0, 'life1, 'async_trait>( &'life0 self, params: &'life1 QueryParams, ) -> Pin<Box<dyn Future<Output = Result<Vec<Metric>, StorageError>> + Send + 'async_trait>> where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait; fn stats<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<StorageStats, StorageError>> + Send + 'async_trait>> where 'life0: 'async_trait, Self: 'async_trait; fn purge<'life0, 'life1, 'async_trait>( &'life0 self, options: &'life1 PurgeOptions, ) -> Pin<Box<dyn Future<Output = Result<u64, StorageError>> + Send + 'async_trait>> where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait; fn purge_all<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<PurgeAllStats, StorageError>> + Send + 'async_trait>> where 'life0: 'async_trait, Self: 'async_trait; fn close<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>> where 'life0: 'async_trait, Self: 'async_trait; fn distinct_resource_keys<'life0, 'life1, 'async_trait>( &'life0 self, signal: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Vec<String>, StorageError>> + Send + 'async_trait>> where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait; fn query_token_usage<'life0, 'life1, 'async_trait>( &'life0 self, start_time: Option<i64>, end_time: Option<i64>, model: Option<&'life1 str>, ) -> Pin<Box<dyn Future<Output = Result<(TokenUsageSummary, Vec<ModelUsage>, Vec<SystemUsage>), StorageError>> + Send + 'async_trait>> where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait; fn query_cost_series<'life0, 'life1, 'async_trait>( &'life0 self, start_time: Option<i64>, end_time: Option<i64>, bucket_ns: i64, model: Option<&'life1 str>, ) -> Pin<Box<dyn Future<Output = Result<Vec<CostSeriesPoint>, StorageError>> + Send + 'async_trait>> where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait; fn query_top_spans<'life0, 'async_trait>( &'life0 self, start_time: Option<i64>, end_time: Option<i64>, limit: usize, sort_by: TopSpanSort, truncated_only: bool, ) -> Pin<Box<dyn Future<Output = Result<Vec<TopSpan>, StorageError>> + Send + 'async_trait>> where 'life0: 'async_trait, Self: 'async_trait; fn query_top_sessions<'life0, 'async_trait>( &'life0 self, start_time: Option<i64>, end_time: Option<i64>, limit: usize, ) -> Pin<Box<dyn Future<Output = Result<Vec<SessionCostRow>, StorageError>> + Send + 'async_trait>> where 'life0: 'async_trait, Self: 'async_trait; fn query_top_conversations<'life0, 'async_trait>( &'life0 self, start_time: Option<i64>, end_time: Option<i64>, limit: usize, ) -> Pin<Box<dyn Future<Output = Result<Vec<ConversationCostRow>, StorageError>> + Send + 'async_trait>> where 'life0: 'async_trait, Self: 'async_trait; fn query_finish_reasons<'life0, 'life1, 'async_trait>( &'life0 self, start_time: Option<i64>, end_time: Option<i64>, model: Option<&'life1 str>, ) -> Pin<Box<dyn Future<Output = Result<Vec<FinishReasonCount>, StorageError>> + Send + 'async_trait>> where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait; fn query_latency_stats<'life0, 'life1, 'async_trait>( &'life0 self, start_time: Option<i64>, end_time: Option<i64>, model: Option<&'life1 str>, ) -> Pin<Box<dyn Future<Output = Result<Vec<LatencyStats>, StorageError>> + Send + 'async_trait>> where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait; fn query_error_rate<'life0, 'life1, 'async_trait>( &'life0 self, start_time: Option<i64>, end_time: Option<i64>, model: Option<&'life1 str>, ) -> Pin<Box<dyn Future<Output = Result<Vec<ErrorRateByModel>, StorageError>> + Send + 'async_trait>> where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait; fn query_tool_usage<'life0, 'async_trait>( &'life0 self, start_time: Option<i64>, end_time: Option<i64>, limit: usize, ) -> Pin<Box<dyn Future<Output = Result<Vec<ToolUsage>, StorageError>> + Send + 'async_trait>> where 'life0: 'async_trait, Self: 'async_trait; fn query_retry_stats<'life0, 'async_trait>( &'life0 self, start_time: Option<i64>, end_time: Option<i64>, ) -> Pin<Box<dyn Future<Output = Result<RetryStats, StorageError>> + Send + 'async_trait>> where 'life0: 'async_trait, Self: 'async_trait; fn query_retrieval_stats<'life0, 'async_trait>( &'life0 self, start_time: Option<i64>, end_time: Option<i64>, top_queries_limit: usize, ) -> Pin<Box<dyn Future<Output = Result<RetrievalStats, StorageError>> + Send + 'async_trait>> where 'life0: 'async_trait, Self: 'async_trait; fn query_truncation_rate<'life0, 'life1, 'async_trait>( &'life0 self, start_time: Option<i64>, end_time: Option<i64>, model: Option<&'life1 str>, ) -> Pin<Box<dyn Future<Output = Result<Vec<TruncationRateByModel>, StorageError>> + Send + 'async_trait>> where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait; fn query_cache_hit_rate<'life0, 'life1, 'async_trait>( &'life0 self, start_time: Option<i64>, end_time: Option<i64>, model: Option<&'life1 str>, ) -> Pin<Box<dyn Future<Output = Result<Vec<CacheHitRateByModel>, StorageError>> + Send + 'async_trait>> where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait; fn query_request_param_profile<'life0, 'async_trait>( &'life0 self, start_time: Option<i64>, end_time: Option<i64>, ) -> Pin<Box<dyn Future<Output = Result<RequestParamProfile, StorageError>> + Send + 'async_trait>> where 'life0: 'async_trait, Self: 'async_trait; fn query_conversation_depth<'life0, 'async_trait>( &'life0 self, start_time: Option<i64>, end_time: Option<i64>, ) -> Pin<Box<dyn Future<Output = Result<ConversationDepthStats, StorageError>> + Send + 'async_trait>> where 'life0: 'async_trait, Self: 'async_trait; fn query_calls_series<'life0, 'async_trait>( &'life0 self, start_time: Option<i64>, end_time: Option<i64>, bucket_secs: u64, ) -> Pin<Box<dyn Future<Output = Result<Vec<CallsSeriesPoint>, StorageError>> + Send + 'async_trait>> where 'life0: 'async_trait, Self: 'async_trait; fn query_error_types<'life0, 'life1, 'async_trait>( &'life0 self, start_time: Option<i64>, end_time: Option<i64>, model: Option<&'life1 str>, ) -> Pin<Box<dyn Future<Output = Result<Vec<ErrorTypeBreakdown>, StorageError>> + Send + 'async_trait>> where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait; fn query_model_drift<'life0, 'async_trait>( &'life0 self, start_time: Option<i64>, end_time: Option<i64>, ) -> Pin<Box<dyn Future<Output = Result<Vec<ModelDriftPair>, StorageError>> + Send + 'async_trait>> where 'life0: 'async_trait, Self: 'async_trait;
}
Expand description

Pluggable storage backend trait.

Both otelite-receiver (writes) and otelite-api (reads) depend only on this trait; neither needs a direct dependency on the SQLite implementation.

Required Methods§

Source

fn initialize<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Source

fn write_log<'life0, 'life1, 'async_trait>( &'life0 self, log: &'life1 LogRecord, ) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Source

fn write_span<'life0, 'life1, 'async_trait>( &'life0 self, span: &'life1 Span, ) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Source

fn write_metric<'life0, 'life1, 'async_trait>( &'life0 self, metric: &'life1 Metric, ) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Source

fn query_logs<'life0, 'life1, 'async_trait>( &'life0 self, params: &'life1 QueryParams, ) -> Pin<Box<dyn Future<Output = Result<Vec<LogRecord>, StorageError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Source

fn query_spans<'life0, 'life1, 'async_trait>( &'life0 self, params: &'life1 QueryParams, ) -> Pin<Box<dyn Future<Output = Result<Vec<Span>, StorageError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Source

fn query_spans_for_trace_list<'life0, 'life1, 'async_trait>( &'life0 self, params: &'life1 QueryParams, trace_limit: usize, ) -> Pin<Box<dyn Future<Output = Result<Vec<Span>, StorageError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Query all spans for the N most-recent distinct traces matching the filters.

Source

fn query_metrics<'life0, 'life1, 'async_trait>( &'life0 self, params: &'life1 QueryParams, ) -> Pin<Box<dyn Future<Output = Result<Vec<Metric>, StorageError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Query metrics (raw time-series rows, latest first).

Source

fn query_latest_metrics<'life0, 'life1, 'async_trait>( &'life0 self, params: &'life1 QueryParams, ) -> Pin<Box<dyn Future<Output = Result<Vec<Metric>, StorageError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Query metrics returning the single most-recent data point per unique name.

Source

fn stats<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<StorageStats, StorageError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Source

fn purge<'life0, 'life1, 'async_trait>( &'life0 self, options: &'life1 PurgeOptions, ) -> Pin<Box<dyn Future<Output = Result<u64, StorageError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Source

fn purge_all<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<PurgeAllStats, StorageError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Source

fn close<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Source

fn distinct_resource_keys<'life0, 'life1, 'async_trait>( &'life0 self, signal: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Vec<String>, StorageError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Return distinct resource attribute keys for the given signal type. signal must be one of "logs", "spans", or "metrics".

Source

fn query_token_usage<'life0, 'life1, 'async_trait>( &'life0 self, start_time: Option<i64>, end_time: Option<i64>, model: Option<&'life1 str>, ) -> Pin<Box<dyn Future<Output = Result<(TokenUsageSummary, Vec<ModelUsage>, Vec<SystemUsage>), StorageError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Source

fn query_cost_series<'life0, 'life1, 'async_trait>( &'life0 self, start_time: Option<i64>, end_time: Option<i64>, bucket_ns: i64, model: Option<&'life1 str>, ) -> Pin<Box<dyn Future<Output = Result<Vec<CostSeriesPoint>, StorageError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Time-bucketed token usage grouped by model for cost-over-time analysis.

bucket_ns is the bucket size in nanoseconds (e.g. 3_600_000_000_000 for 1h).

Source

fn query_top_spans<'life0, 'async_trait>( &'life0 self, start_time: Option<i64>, end_time: Option<i64>, limit: usize, sort_by: TopSpanSort, truncated_only: bool, ) -> Pin<Box<dyn Future<Output = Result<Vec<TopSpan>, StorageError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Top-N LLM spans ordered by the given sort dimension.

When truncated_only is true, only spans whose finish reason is max_tokens or length are returned.

Source

fn query_top_sessions<'life0, 'async_trait>( &'life0 self, start_time: Option<i64>, end_time: Option<i64>, limit: usize, ) -> Pin<Box<dyn Future<Output = Result<Vec<SessionCostRow>, StorageError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Top-N sessions by total tokens, suitable for cost enrichment.

Source

fn query_top_conversations<'life0, 'async_trait>( &'life0 self, start_time: Option<i64>, end_time: Option<i64>, limit: usize, ) -> Pin<Box<dyn Future<Output = Result<Vec<ConversationCostRow>, StorageError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Top-N conversations (gen_ai.conversation.id) by total tokens.

Source

fn query_finish_reasons<'life0, 'life1, 'async_trait>( &'life0 self, start_time: Option<i64>, end_time: Option<i64>, model: Option<&'life1 str>, ) -> Pin<Box<dyn Future<Output = Result<Vec<FinishReasonCount>, StorageError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Finish-reason distribution across LLM spans and Claude Code api_response_body logs.

Source

fn query_latency_stats<'life0, 'life1, 'async_trait>( &'life0 self, start_time: Option<i64>, end_time: Option<i64>, model: Option<&'life1 str>, ) -> Pin<Box<dyn Future<Output = Result<Vec<LatencyStats>, StorageError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Latency (and optional TTFT) percentile statistics per model for LLM spans.

Source

fn query_error_rate<'life0, 'life1, 'async_trait>( &'life0 self, start_time: Option<i64>, end_time: Option<i64>, model: Option<&'life1 str>, ) -> Pin<Box<dyn Future<Output = Result<Vec<ErrorRateByModel>, StorageError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Error rate by model across LLM spans.

Source

fn query_tool_usage<'life0, 'async_trait>( &'life0 self, start_time: Option<i64>, end_time: Option<i64>, limit: usize, ) -> Pin<Box<dyn Future<Output = Result<Vec<ToolUsage>, StorageError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Aggregated tool-execution usage counts and durations.

Source

fn query_retry_stats<'life0, 'async_trait>( &'life0 self, start_time: Option<i64>, end_time: Option<i64>, ) -> Pin<Box<dyn Future<Output = Result<RetryStats, StorageError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Retry statistics across LLM spans.

Source

fn query_retrieval_stats<'life0, 'async_trait>( &'life0 self, start_time: Option<i64>, end_time: Option<i64>, top_queries_limit: usize, ) -> Pin<Box<dyn Future<Output = Result<RetrievalStats, StorageError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Aggregated retrieval / RAG statistics across retriever spans.

Source

fn query_truncation_rate<'life0, 'life1, 'async_trait>( &'life0 self, start_time: Option<i64>, end_time: Option<i64>, model: Option<&'life1 str>, ) -> Pin<Box<dyn Future<Output = Result<Vec<TruncationRateByModel>, StorageError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Truncation rate (finish_reason = max_tokens / length) per model.

Source

fn query_cache_hit_rate<'life0, 'life1, 'async_trait>( &'life0 self, start_time: Option<i64>, end_time: Option<i64>, model: Option<&'life1 str>, ) -> Pin<Box<dyn Future<Output = Result<Vec<CacheHitRateByModel>, StorageError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Cache token hit rate per model.

Source

fn query_request_param_profile<'life0, 'async_trait>( &'life0 self, start_time: Option<i64>, end_time: Option<i64>, ) -> Pin<Box<dyn Future<Output = Result<RequestParamProfile, StorageError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Distribution of request parameter settings (temperature, max_tokens).

Source

fn query_conversation_depth<'life0, 'async_trait>( &'life0 self, start_time: Option<i64>, end_time: Option<i64>, ) -> Pin<Box<dyn Future<Output = Result<ConversationDepthStats, StorageError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Turn-count distribution across conversations with a known conversation_id.

Source

fn query_calls_series<'life0, 'async_trait>( &'life0 self, start_time: Option<i64>, end_time: Option<i64>, bucket_secs: u64, ) -> Pin<Box<dyn Future<Output = Result<Vec<CallsSeriesPoint>, StorageError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

LLM call volume per time bucket (parallel to query_cost_series).

Source

fn query_error_types<'life0, 'life1, 'async_trait>( &'life0 self, start_time: Option<i64>, end_time: Option<i64>, model: Option<&'life1 str>, ) -> Pin<Box<dyn Future<Output = Result<Vec<ErrorTypeBreakdown>, StorageError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Per-(model, error_type) breakdown of error spans, bucketed into actionable categories.

Source

fn query_model_drift<'life0, 'async_trait>( &'life0 self, start_time: Option<i64>, end_time: Option<i64>, ) -> Pin<Box<dyn Future<Output = Result<Vec<ModelDriftPair>, StorageError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

All observed (request_model, response_model) pairs with a differs flag.

Implementors§