use commonware_runtime::telemetry::metrics::{Gauge, GaugeExt, MetricsExt};
pub struct Metrics {
target_size: Gauge,
size: Gauge,
}
impl Metrics {
pub fn new(context: &impl commonware_runtime::Metrics) -> Self {
Self {
target_size: context.gauge("target_size", "Size of the current sync target"),
size: context.gauge(
"size",
"Database size reached by sync, equal to target_size when sync completes",
),
}
}
pub fn record_target(&self, size: u64) {
let _ = self.target_size.try_set(size);
}
pub fn record_synced(&self, size: u64) {
let _ = self.size.try_set(size);
}
}