pub trait MetricsStorage:
Send
+ Sync
+ 'static {
// Required method
fn backend(&self) -> &dyn StorageBackend;
// Provided methods
fn init<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), Status>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
fn insert_metrics<'life0, 'async_trait>(
&'life0 self,
metrics: Vec<MetricRecord>,
) -> Pin<Box<dyn Future<Output = Result<(), Status>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
fn query_metrics<'life0, 'async_trait>(
&'life0 self,
from_timestamp: i64,
) -> Pin<Box<dyn Future<Output = Result<Vec<MetricRecord>, Status>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
fn aggregate_metrics<'life0, 'life1, 'async_trait>(
&'life0 self,
function: AggregateFunction,
group_by: &'life1 GroupBy,
from_timestamp: i64,
to_timestamp: Option<i64>,
) -> Pin<Box<dyn Future<Output = Result<Vec<AggregateResult>, Status>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn get_metrics_schema() -> Schema { ... }
fn generate_metric_insert_sql() -> String { ... }
fn generate_metric_query_sql(from_timestamp: i64) -> String { ... }
fn generate_metric_aggregation_sql(
function: AggregateFunction,
group_by: &GroupBy,
from_timestamp: i64,
to_timestamp: Option<i64>,
) -> String { ... }
}Expand description
Storage operations specific to metrics data.
Required Methods§
Sourcefn backend(&self) -> &dyn StorageBackend
fn backend(&self) -> &dyn StorageBackend
Get the underlying storage backend
Provided Methods§
Sourcefn init<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), Status>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn init<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), Status>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Initialize metrics storage (create schema-v2 tables, migrate pre-v2 metrics).
Sourcefn insert_metrics<'life0, 'async_trait>(
&'life0 self,
metrics: Vec<MetricRecord>,
) -> Pin<Box<dyn Future<Output = Result<(), Status>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn insert_metrics<'life0, 'async_trait>(
&'life0 self,
metrics: Vec<MetricRecord>,
) -> Pin<Box<dyn Future<Output = Result<(), Status>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Insert metrics into storage
Sourcefn query_metrics<'life0, 'async_trait>(
&'life0 self,
from_timestamp: i64,
) -> Pin<Box<dyn Future<Output = Result<Vec<MetricRecord>, Status>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn query_metrics<'life0, 'async_trait>(
&'life0 self,
from_timestamp: i64,
) -> Pin<Box<dyn Future<Output = Result<Vec<MetricRecord>, Status>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Query metrics from storage
Sourcefn aggregate_metrics<'life0, 'life1, 'async_trait>(
&'life0 self,
function: AggregateFunction,
group_by: &'life1 GroupBy,
from_timestamp: i64,
to_timestamp: Option<i64>,
) -> Pin<Box<dyn Future<Output = Result<Vec<AggregateResult>, Status>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn aggregate_metrics<'life0, 'life1, 'async_trait>(
&'life0 self,
function: AggregateFunction,
group_by: &'life1 GroupBy,
from_timestamp: i64,
to_timestamp: Option<i64>,
) -> Pin<Box<dyn Future<Output = Result<Vec<AggregateResult>, Status>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Aggregate metrics using the specified function and grouping
Sourcefn get_metrics_schema() -> Schema
fn get_metrics_schema() -> Schema
Get the standard schema for metric records
Sourcefn generate_metric_insert_sql() -> String
fn generate_metric_insert_sql() -> String
Generate SQL for inserting metric records
Sourcefn generate_metric_query_sql(from_timestamp: i64) -> String
fn generate_metric_query_sql(from_timestamp: i64) -> String
Generate SQL for querying metrics
Sourcefn generate_metric_aggregation_sql(
function: AggregateFunction,
group_by: &GroupBy,
from_timestamp: i64,
to_timestamp: Option<i64>,
) -> String
fn generate_metric_aggregation_sql( function: AggregateFunction, group_by: &GroupBy, from_timestamp: i64, to_timestamp: Option<i64>, ) -> String
Generate SQL for aggregating metrics
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.