use commonware_runtime::telemetry::metrics::{Gauge, GaugeExt, MetricsExt};
pub struct Metrics {
target_leaf_count: Gauge,
leaf_count: Gauge,
}
impl Metrics {
pub fn new(context: &impl commonware_runtime::Metrics) -> Self {
Self {
target_leaf_count: context.gauge(
"target_leaf_count",
"Total leaves in the current sync target",
),
leaf_count: context.gauge(
"leaf_count",
"Leaves synced so far, equal to target_leaf_count when sync completes",
),
}
}
pub fn record_target(&self, leaf_count: u64) {
let _ = self.target_leaf_count.try_set(leaf_count);
}
pub fn record_synced(&self, leaf_count: u64) {
let _ = self.leaf_count.try_set(leaf_count);
}
}