commonware_storage/qmdb/sync/
metrics.rs1use commonware_runtime::telemetry::metrics::{Gauge, GaugeExt, MetricsExt};
2
3pub struct Metrics {
9 target_leaf_count: Gauge,
11 leaf_count: Gauge,
13}
14
15impl Metrics {
16 pub fn new(context: &impl commonware_runtime::Metrics) -> Self {
18 Self {
19 target_leaf_count: context.gauge(
20 "target_leaf_count",
21 "Total leaves in the current sync target",
22 ),
23 leaf_count: context.gauge(
24 "leaf_count",
25 "Leaves synced so far, equal to target_leaf_count when sync completes",
26 ),
27 }
28 }
29
30 pub fn record_target(&self, leaf_count: u64) {
32 let _ = self.target_leaf_count.try_set(leaf_count);
33 }
34
35 pub fn record_synced(&self, leaf_count: u64) {
37 let _ = self.leaf_count.try_set(leaf_count);
38 }
39}