use reth_metrics::{
metrics::{Gauge, Histogram},
Metrics,
};
use reth_prune_types::PruneSegment;
use std::collections::HashMap;
#[derive(Metrics)]
#[metrics(scope = "pruner")]
pub(crate) struct Metrics {
pub(crate) duration_seconds: Histogram,
#[metric(skip)]
prune_segments: HashMap<PruneSegment, PrunerSegmentMetrics>,
}
impl Metrics {
pub(crate) fn get_prune_segment_metrics(
&mut self,
segment: PruneSegment,
) -> &mut PrunerSegmentMetrics {
self.prune_segments.entry(segment).or_insert_with(|| {
PrunerSegmentMetrics::new_with_labels(&[("segment", segment.to_string())])
})
}
}
#[derive(Metrics)]
#[metrics(scope = "pruner.segments")]
pub(crate) struct PrunerSegmentMetrics {
pub(crate) duration_seconds: Histogram,
pub(crate) highest_pruned_block: Gauge,
}