1use std::sync::Arc;
6
7use prometheus::{IntGauge, Registry, register_int_gauge_with_registry};
8
9pub struct EpochMetrics {
10 pub current_epoch: IntGauge,
13
14 pub current_voting_right: IntGauge,
17
18 pub epoch_total_duration: IntGauge,
22
23 pub epoch_checkpoint_count: IntGauge,
25
26 pub epoch_transaction_count: IntGauge,
28
29 pub epoch_total_gas_reward: IntGauge,
31
32 pub epoch_pending_certs_processed_time_since_epoch_close_ms: IntGauge,
48
49 pub epoch_end_of_publish_quorum_time_since_epoch_close_ms: IntGauge,
53
54 pub epoch_last_checkpoint_created_time_since_epoch_close_ms: IntGauge,
58
59 pub epoch_reconfig_start_time_since_epoch_close_ms: IntGauge,
64
65 pub epoch_validator_halt_duration_ms: IntGauge,
70
71 pub epoch_first_checkpoint_created_time_since_epoch_begin_ms: IntGauge,
78
79 pub is_safe_mode: IntGauge,
82
83 pub checkpoint_builder_advance_epoch_is_safe_mode: IntGauge,
88
89 pub effective_buffer_stake: IntGauge,
91
92 pub epoch_random_beacon_dkg_failed: IntGauge,
95
96 pub epoch_random_beacon_dkg_num_shares: IntGauge,
99
100 pub epoch_random_beacon_dkg_epoch_start_completion_time_ms: IntGauge,
103
104 pub epoch_random_beacon_dkg_completion_time_ms: IntGauge,
108
109 pub epoch_random_beacon_dkg_message_time_ms: IntGauge,
113
114 pub epoch_random_beacon_dkg_confirmation_time_ms: IntGauge,
118}
119
120impl EpochMetrics {
121 pub fn new(registry: &Registry) -> Arc<Self> {
122 let this = Self {
123 current_epoch: register_int_gauge_with_registry!(
124 "current_epoch",
125 "Current epoch ID",
126 registry
127 )
128 .unwrap(),
129 current_voting_right: register_int_gauge_with_registry!(
130 "current_voting_right",
131 "Current voting right of the validator",
132 registry
133 )
134 .unwrap(),
135 epoch_checkpoint_count: register_int_gauge_with_registry!(
136 "epoch_checkpoint_count",
137 "Number of checkpoints in the epoch",
138 registry
139 ).unwrap(),
140 epoch_total_duration: register_int_gauge_with_registry!(
141 "epoch_total_duration",
142 "Total duration of the epoch",
143 registry
144 ).unwrap(),
145 epoch_transaction_count: register_int_gauge_with_registry!(
146 "epoch_transaction_count",
147 "Number of transactions in the epoch",
148 registry
149 ).unwrap(),
150 epoch_total_gas_reward: register_int_gauge_with_registry!(
151 "epoch_total_gas_reward",
152 "Total amount of gas rewards (i.e. computation gas cost) in the epoch",
153 registry
154 ).unwrap(),
155 epoch_pending_certs_processed_time_since_epoch_close_ms: register_int_gauge_with_registry!(
156 "epoch_pending_certs_processed_time_since_epoch_close_ms",
157 "Time interval from when epoch was closed to when all pending certificates are processed",
158 registry
159 ).unwrap(),
160 epoch_end_of_publish_quorum_time_since_epoch_close_ms: register_int_gauge_with_registry!(
161 "epoch_end_of_publish_quorum_time_since_epoch_close_ms",
162 "Time interval from when epoch was closed to when 2f+1 EndOfPublish messages are received",
163 registry
164 ).unwrap(),
165 epoch_last_checkpoint_created_time_since_epoch_close_ms: register_int_gauge_with_registry!(
166 "epoch_last_checkpoint_created_time_since_epoch_close_ms",
167 "Time interval from when epoch was closed to when the last checkpoint of the epoch is created",
168 registry
169 ).unwrap(),
170 epoch_reconfig_start_time_since_epoch_close_ms: register_int_gauge_with_registry!(
171 "epoch_reconfig_start_time_since_epoch_close_ms",
172 "Total time duration from when epoch was closed to when we begin to reconfigure the validator",
173 registry
174 ).unwrap(),
175 epoch_validator_halt_duration_ms: register_int_gauge_with_registry!(
176 "epoch_validator_halt_duration_ms",
177 "Total time duration when the validator was halted (i.e. epoch closed)",
178 registry
179 ).unwrap(),
180 epoch_first_checkpoint_created_time_since_epoch_begin_ms: register_int_gauge_with_registry!(
181 "epoch_first_checkpoint_created_time_since_epoch_begin_ms",
182 "Time interval from when the epoch opens at new epoch to the first checkpoint is created locally",
183 registry
184 ).unwrap(),
185 is_safe_mode: register_int_gauge_with_registry!(
186 "is_safe_mode",
187 "Whether we are running in safe mode",
188 registry,
189 ).unwrap(),
190 checkpoint_builder_advance_epoch_is_safe_mode: register_int_gauge_with_registry!(
191 "checkpoint_builder_advance_epoch_is_safe_mode",
192 "Whether the advance epoch execution leads to safe mode while building the last checkpoint",
193 registry,
194 ).unwrap(),
195 effective_buffer_stake: register_int_gauge_with_registry!(
196 "effective_buffer_stake",
197 "Buffer stake current in effect for this epoch",
198 registry,
199 ).unwrap(),
200 epoch_random_beacon_dkg_failed: register_int_gauge_with_registry!(
201 "epoch_random_beacon_dkg_failed",
202 "Set to 1 if the random beacon DKG protocol failed for the most recent epoch.",
203 registry
204 )
205 .unwrap(),
206 epoch_random_beacon_dkg_num_shares: register_int_gauge_with_registry!(
207 "epoch_random_beacon_dkg_num_shares",
208 "The number of shares held by this node after the random beacon DKG protocol completed",
209 registry
210 )
211 .unwrap(),
212 epoch_random_beacon_dkg_epoch_start_completion_time_ms: register_int_gauge_with_registry!(
213 "epoch_random_beacon_dkg_epoch_start_completion_time_ms",
214 "The amount of time taken from epoch start to completion of random beacon DKG protocol, for the most recent epoch",
215 registry
216 )
217 .unwrap(),
218 epoch_random_beacon_dkg_completion_time_ms: register_int_gauge_with_registry!(
219 "epoch_random_beacon_dkg_completion_time_ms",
220 "The amount of time taken to complete random beacon DKG protocol from the time it was started (which may be a bit after the epoch began), for the most recent epoch",
221 registry
222 )
223 .unwrap(),
224 epoch_random_beacon_dkg_message_time_ms: register_int_gauge_with_registry!(
225 "epoch_random_beacon_dkg_message_time_ms",
226 "The amount of time taken to start first phase of the random beacon DKG protocol, at which point the node has submitted a DKG Message, for the most recent epoch",
227 registry
228 )
229 .unwrap(),
230 epoch_random_beacon_dkg_confirmation_time_ms: register_int_gauge_with_registry!(
231 "epoch_random_beacon_dkg_confirmation_time_ms",
232 "The amount of time taken to complete first phase of the random beacon DKG protocol, at which point the node has submitted a DKG Confirmation, for the most recent epoch",
233 registry
234 )
235 .unwrap(),
236 };
237 Arc::new(this)
238 }
239}