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