Skip to main content

MetricsRecorder

Trait MetricsRecorder 

Source
pub trait MetricsRecorder:
    DbMetricsRecorder
    + Send
    + Sync {
    // Provided methods
    fn record_http_request(
        &self,
        method: &str,
        route: &str,
        status: u16,
        duration_seconds: f64,
    ) { ... }
    fn record_auth_event(
        &self,
        action: &'static str,
        status: &'static str,
        reason: &'static str,
    ) { ... }
    fn record_application_event(
        &self,
        category: &'static str,
        event: &'static str,
        status: &'static str,
    ) { ... }
    fn record_config_reload(
        &self,
        source: &'static str,
        decision: &'static str,
        status: &'static str,
        changed_keys: u64,
        duration_seconds: f64,
    ) { ... }
    fn record_config_mutation(
        &self,
        source: &'static str,
        operation: &'static str,
        status: &'static str,
        changed_keys: u64,
    ) { ... }
    fn record_background_task_transition(
        &self,
        kind: &'static str,
        status: &'static str,
    ) { ... }
    fn set_background_tasks_pending(&self, pending: u64) { ... }
    fn record_external_operation(
        &self,
        system: &'static str,
        operation: &'static str,
        status: &'static str,
        duration_seconds: f64,
    ) { ... }
    fn system_metrics_updater_task(
        &self,
        shutdown_token: CancellationToken,
    ) -> Option<Pin<Box<dyn Future<Output = ()> + Send + 'static>>> { ... }
}
Expand description

Application-wide metrics recorder interface.

Product crates should keep domain-specific metrics in extension traits or subsystem recorders. The methods here cover infrastructure signals that are shared by Aster services.

Provided Methods§

Source

fn record_http_request( &self, method: &str, route: &str, status: u16, duration_seconds: f64, )

Records an HTTP request.

method and route become metric label values and MUST be low cardinality: pass the route template (e.g. /api/v1/files/{id}), never the raw request path. Raw paths containing IDs or UUIDs allocate a new, never-freed time series per distinct value — a user-input-driven memory bomb.

Source

fn record_auth_event( &self, action: &'static str, status: &'static str, reason: &'static str, )

Records an authentication event.

Source

fn record_application_event( &self, category: &'static str, event: &'static str, status: &'static str, )

Records a generic application event.

Source

fn record_config_reload( &self, source: &'static str, decision: &'static str, status: &'static str, changed_keys: u64, duration_seconds: f64, )

Records a runtime configuration reload attempt.

Source

fn record_config_mutation( &self, source: &'static str, operation: &'static str, status: &'static str, changed_keys: u64, )

Records a runtime configuration mutation.

Source

fn record_background_task_transition( &self, kind: &'static str, status: &'static str, )

Records a background task state transition.

Source

fn set_background_tasks_pending(&self, pending: u64)

Sets the number of pending background tasks.

Source

fn record_external_operation( &self, system: &'static str, operation: &'static str, status: &'static str, duration_seconds: f64, )

Records an operation against an external system.

Source

fn system_metrics_updater_task( &self, shutdown_token: CancellationToken, ) -> Option<Pin<Box<dyn Future<Output = ()> + Send + 'static>>>

Creates an optional background task that updates system-level metrics.

Implementors§