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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
use prometheus::{
    default_registry, register_int_counter_with_registry, register_int_gauge_vec_with_registry,
    register_int_gauge_with_registry, IntCounter, IntGauge, IntGaugeVec, Registry,
};
#[derive(Clone, Debug)]
pub struct ConsensusMetrics {
    pub consensus_dag_rounds: IntGaugeVec,
    pub last_committed_round: IntGaugeVec,
    pub external_consensus_dag_vertices_elements: IntGaugeVec,
    pub external_consensus_dag_size: IntGaugeVec,
    pub recovered_consensus_state: IntCounter,
    pub recovered_consensus_output: IntCounter,
    pub dag_size_bytes: IntGauge,
}
impl ConsensusMetrics {
    pub fn new(registry: &Registry) -> Self {
        Self {
            consensus_dag_rounds: register_int_gauge_vec_with_registry!(
                "consensus_dag_rounds",
                "The number of rounds for which the consensus Dag holds certificates",
                &[],
                registry
            ).unwrap(),
            last_committed_round: register_int_gauge_vec_with_registry!(
                "last_committed_round",
                "The most recent round that has been committed from consensus",
                &[],
                registry
            ).unwrap(),
            external_consensus_dag_vertices_elements: register_int_gauge_vec_with_registry!(
                "external_consensus_dag_vertices_elements",
                "The number of elements in the vertices secondary index in the inner dag structure (external consensus)",
                &[],
                registry
            ).unwrap(),
            external_consensus_dag_size: register_int_gauge_vec_with_registry!(
                "external_consensus_dag_size",
                "The number of elements in the inner dag (external consensus)",
                &[],
                registry
            ).unwrap(),
            recovered_consensus_state: register_int_counter_with_registry!(
                "recovered_consensus_state",
                "The number of times the consensus state was restored from the consensus store following a node restart",
                registry
            ).unwrap(),
            recovered_consensus_output: register_int_counter_with_registry!(
                "recovered_consensus_output", 
                "The number of certificates from consensus that were restored and sent to the executor following a node restart",
                registry
            ).unwrap(),
            dag_size_bytes: register_int_gauge_with_registry!(
                "dag_size_bytes",
                "The approximate size in memory (including heap allocations) of the dag",
                registry
            ).unwrap(),
        }
    }
}
impl Default for ConsensusMetrics {
    fn default() -> Self {
        Self::new(default_registry())
    }
}
#[derive(Clone, Debug)]
pub struct ChannelMetrics {
    pub tx_sequence: IntGauge,
}
impl ChannelMetrics {
    pub fn new(registry: &Registry) -> Self {
        Self {
            tx_sequence: register_int_gauge_with_registry!(
                "tx_sequence",
                "occupancy of the channel from the `Consensus` to `SubscriberHandler`",
                registry
            )
            .unwrap(),
        }
    }
}
impl Default for ChannelMetrics {
    fn default() -> Self {
        Self::new(default_registry())
    }
}