-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
Copy pathmetrics.rs
32 lines (29 loc) · 947 Bytes
/
metrics.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
use reth_metrics::{metrics, metrics::Histogram, Metrics};
use reth_primitives::PrunePart;
use std::collections::HashMap;
#[derive(Metrics)]
#[metrics(scope = "pruner")]
pub(crate) struct Metrics {
/// Pruning duration
pub(crate) duration_seconds: Histogram,
#[metric(skip)]
prune_parts: HashMap<PrunePart, PrunerPartMetrics>,
}
impl Metrics {
/// Returns existing or initializes a new instance of [PrunerPartMetrics] for the provided
/// [PrunePart].
pub(crate) fn get_prune_part_metrics(
&mut self,
prune_part: PrunePart,
) -> &mut PrunerPartMetrics {
self.prune_parts.entry(prune_part).or_insert_with(|| {
PrunerPartMetrics::new_with_labels(&[("part", prune_part.to_string())])
})
}
}
#[derive(Metrics)]
#[metrics(scope = "pruner.parts")]
pub(crate) struct PrunerPartMetrics {
/// Pruning duration for this part
pub(crate) duration_seconds: Histogram,
}