iota_core/checkpoints/
metrics.rs1use std::sync::Arc;
6
7use iota_metrics::histogram::Histogram;
8use prometheus::{
9 IntCounter, IntCounterVec, IntGauge, IntGaugeVec, Registry,
10 register_int_counter_vec_with_registry, register_int_counter_with_registry,
11 register_int_gauge_vec_with_registry, register_int_gauge_with_registry,
12};
13
14pub struct CheckpointMetrics {
15 pub last_certified_checkpoint: IntGauge,
16 pub last_constructed_checkpoint: IntGauge,
17 pub checkpoint_errors: IntCounter,
18 pub transactions_included_in_checkpoint: IntCounter,
19 pub checkpoint_roots_count: IntCounter,
20 pub checkpoint_participation: IntCounterVec,
21 pub last_received_checkpoint_signatures: IntGaugeVec,
22 pub last_sent_checkpoint_signature: IntGauge,
23 pub last_skipped_checkpoint_signature_submission: IntGauge,
24 pub last_ignored_checkpoint_signature_received: IntGauge,
25 pub highest_accumulated_epoch: IntGauge,
26 pub checkpoint_creation_latency_ms: Histogram,
27 pub remote_checkpoint_forks: IntCounter,
28 pub split_brain_checkpoint_forks: IntCounter,
29 pub last_created_checkpoint_age_ms: Histogram,
30 pub last_certified_checkpoint_age_ms: Histogram,
31}
32
33impl CheckpointMetrics {
34 pub fn new(registry: &Registry) -> Arc<Self> {
35 let this = Self {
36 last_certified_checkpoint: register_int_gauge_with_registry!(
37 "last_certified_checkpoint",
38 "Last certified checkpoint",
39 registry
40 )
41 .unwrap(),
42 last_constructed_checkpoint: register_int_gauge_with_registry!(
43 "last_constructed_checkpoint",
44 "Last constructed checkpoint",
45 registry
46 )
47 .unwrap(),
48 last_created_checkpoint_age_ms: Histogram::new_in_registry(
49 "last_created_checkpoint_age_ms",
50 "Age of the last created checkpoint",
51 registry,
52 ),
53 last_certified_checkpoint_age_ms: Histogram::new_in_registry(
54 "last_certified_checkpoint_age_ms",
55 "Age of the last certified checkpoint",
56 registry,
57 ),
58 checkpoint_errors: register_int_counter_with_registry!(
59 "checkpoint_errors",
60 "Checkpoints errors count",
61 registry
62 )
63 .unwrap(),
64 transactions_included_in_checkpoint: register_int_counter_with_registry!(
65 "transactions_included_in_checkpoint",
66 "Transactions included in a checkpoint",
67 registry
68 )
69 .unwrap(),
70 checkpoint_roots_count: register_int_counter_with_registry!(
71 "checkpoint_roots_count",
72 "Number of checkpoint roots received from consensus",
73 registry
74 )
75 .unwrap(),
76 checkpoint_participation: register_int_counter_vec_with_registry!(
77 "checkpoint_participation",
78 "Participation in checkpoint certification by validator",
79 &["signer"],
80 registry
81 )
82 .unwrap(),
83 last_received_checkpoint_signatures: register_int_gauge_vec_with_registry!(
84 "last_received_checkpoint_signatures",
85 "Last received checkpoint signatures by validator",
86 &["signer"],
87 registry
88 )
89 .unwrap(),
90 last_sent_checkpoint_signature: register_int_gauge_with_registry!(
91 "last_sent_checkpoint_signature",
92 "Last checkpoint signature sent by myself",
93 registry
94 )
95 .unwrap(),
96 last_skipped_checkpoint_signature_submission: register_int_gauge_with_registry!(
97 "last_skipped_checkpoint_signature_submission",
98 "Last checkpoint signature that this validator skipped submitting because it was already certified.",
99 registry
100 )
101 .unwrap(),
102 last_ignored_checkpoint_signature_received: register_int_gauge_with_registry!(
103 "last_ignored_checkpoint_signature_received",
104 "Last received checkpoint signature that this validator ignored because it was already certified.",
105 registry
106 )
107 .unwrap(),
108 highest_accumulated_epoch: register_int_gauge_with_registry!(
109 "highest_accumulated_epoch",
110 "Highest accumulated epoch",
111 registry
112 )
113 .unwrap(),
114 checkpoint_creation_latency_ms: Histogram::new_in_registry(
115 "checkpoint_creation_latency_ms",
116 "Latency from consensus commit timestamp to local checkpoint creation in milliseconds",
117 registry,
118 ),
119 remote_checkpoint_forks: register_int_counter_with_registry!(
120 "remote_checkpoint_forks",
121 "Number of remote checkpoints that forked from local checkpoints",
122 registry
123 )
124 .unwrap(),
125 split_brain_checkpoint_forks: register_int_counter_with_registry!(
126 "split_brain_checkpoint_forks",
127 "Number of checkpoints that have resulted in a split brain",
128 registry
129 )
130 .unwrap(),
131 };
132 Arc::new(this)
133 }
134
135 pub fn new_for_tests() -> Arc<Self> {
136 Self::new(&Registry::new())
137 }
138}