pub trait MetricsCollector:
Send
+ Sync
+ 'static {
// Required methods
fn inc_counter(&self, name: &str, value: u64);
fn record_histogram(&self, name: &str, value: f64);
fn set_gauge(&self, name: &str, value: u64);
}Expand description
Trait for collecting metrics during graph execution.
Implementations can forward to OpenTelemetry, in-memory stores, or any
other metrics backend. Injected via [RunnableConfig::with_metrics_collector].
The trait lives in juncture-core so the Pregel engine can emit metrics
without depending on juncture-tracing. The juncture-tracing crate
provides concrete implementations (TestMetricsCollector, RegistryMetricsCollector).
§Examples
ⓘ
use std::sync::Arc;
use juncture_core::observability::MetricsCollector;
use juncture_core::config::RunnableConfig;
let collector: Arc<dyn MetricsCollector> = /* ... */;
let config = RunnableConfig::new()
.with_metrics_collector(collector);Required Methods§
Sourcefn inc_counter(&self, name: &str, value: u64)
fn inc_counter(&self, name: &str, value: u64)
Increment a counter metric by value.
Sourcefn record_histogram(&self, name: &str, value: f64)
fn record_histogram(&self, name: &str, value: f64)
Record value to a histogram metric.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".