sequencer/persistence/
persistence_metrics.rs

1use hotshot_types::traits::metrics::{Histogram, Metrics, NoMetrics};
2
3/// Metrics for the persistence layer
4#[derive(Clone, Debug)]
5pub struct PersistenceMetricsValue {
6    /// Time taken by the underlying storage to execute the command that appends a VID
7    pub internal_append_vid_duration: Box<dyn Histogram>,
8    /// Time taken by the underlying storage to execute the command that appends DA
9    pub internal_append_da_duration: Box<dyn Histogram>,
10    /// Time taken by the underlying storage to execute the command that appends DA 2
11    pub internal_append_da2_duration: Box<dyn Histogram>,
12    /// Time taken by the underlying storage to execute the command that appends Quorum Proposal 2
13    pub internal_append_quorum2_duration: Box<dyn Histogram>,
14}
15
16impl PersistenceMetricsValue {
17    /// Create a new instance of this [`PersistenceMetricsValue`] struct, setting all the counters and gauges
18    #[must_use]
19    pub fn new(metrics: &dyn Metrics) -> Self {
20        Self {
21            internal_append_vid_duration: metrics.create_histogram(
22                String::from("internal_append_vid_duration"),
23                Some("seconds".to_string()),
24            ),
25            internal_append_da_duration: metrics.create_histogram(
26                String::from("internal_append_da_duration"),
27                Some("seconds".to_string()),
28            ),
29            internal_append_da2_duration: metrics.create_histogram(
30                String::from("internal_append_da2_duration"),
31                Some("seconds".to_string()),
32            ),
33            internal_append_quorum2_duration: metrics.create_histogram(
34                String::from("internal_append_quorum2_duration"),
35                Some("seconds".to_string()),
36            ),
37        }
38    }
39}
40
41impl Default for PersistenceMetricsValue {
42    fn default() -> Self {
43        Self::new(&*NoMetrics::boxed())
44    }
45}