1use prometheus::{
5 CounterVec, IntCounter, IntCounterVec, IntGauge, Registry, register_counter_vec_with_registry,
6 register_int_counter_vec_with_registry, register_int_counter_with_registry,
7 register_int_gauge_with_registry,
8};
9use std::sync::Arc;
10
11pub struct EpochMetrics {
12 pub current_epoch: IntGauge,
14
15 pub current_voting_right: IntGauge,
17
18 pub epoch_total_duration: IntGauge,
21
22 pub epoch_checkpoint_count: IntGauge,
24
25 pub epoch_transaction_count: IntGauge,
27
28 pub epoch_total_gas_reward: IntGauge,
30
31 pub epoch_pending_certs_processed_time_since_epoch_close_ms: IntGauge,
46
47 pub epoch_end_of_publish_quorum_time_since_epoch_close_ms: IntGauge,
50
51 pub epoch_last_checkpoint_created_time_since_epoch_close_ms: IntGauge,
55
56 pub epoch_reconfig_start_time_since_epoch_close_ms: IntGauge,
60
61 pub epoch_validator_halt_duration_ms: IntGauge,
65
66 pub epoch_first_checkpoint_created_time_since_epoch_begin_ms: IntGauge,
72
73 pub is_safe_mode: IntGauge,
75
76 pub checkpoint_builder_advance_epoch_is_safe_mode: IntGauge,
80
81 pub effective_buffer_stake: IntGauge,
83
84 pub epoch_random_beacon_dkg_failed: IntGauge,
86
87 pub epoch_random_beacon_dkg_num_shares: IntGauge,
89
90 pub epoch_random_beacon_dkg_epoch_start_completion_time_ms: IntGauge,
93
94 pub epoch_random_beacon_dkg_completion_time_ms: IntGauge,
97
98 pub epoch_random_beacon_dkg_message_time_ms: IntGauge,
101
102 pub epoch_random_beacon_dkg_confirmation_time_ms: IntGauge,
105
106 pub epoch_execution_time_observations_shared: IntCounter,
108
109 pub epoch_execution_time_observations_sharing_reason: IntCounterVec,
111
112 pub epoch_execution_time_measurements_dropped: IntCounter,
114
115 pub epoch_execution_time_observations_dropped: IntCounterVec,
117
118 pub epoch_execution_time_observer_indebted_objects: IntGauge,
120
121 pub epoch_execution_time_observer_utilization_cache_size: IntGauge,
123
124 pub epoch_execution_time_observer_overutilized_objects: IntGauge,
128
129 pub epoch_execution_time_observer_object_utilization: CounterVec,
133
134 pub epoch_execution_time_observer_tracked_object_utilization: CounterVec,
139
140 pub epoch_execution_time_observations_loaded: IntGauge,
142
143 pub consensus_quarantine_queue_size: IntGauge,
145
146 pub shared_object_assignments_size: IntGauge,
148}
149
150impl EpochMetrics {
151 pub fn new(registry: &Registry) -> Arc<Self> {
152 let this = Self {
153 current_epoch: register_int_gauge_with_registry!(
154 "current_epoch",
155 "Current epoch ID",
156 registry
157 )
158 .unwrap(),
159 current_voting_right: register_int_gauge_with_registry!(
160 "current_voting_right",
161 "Current voting right of the validator",
162 registry
163 )
164 .unwrap(),
165 epoch_checkpoint_count: register_int_gauge_with_registry!(
166 "epoch_checkpoint_count",
167 "Number of checkpoints in the epoch",
168 registry
169 ).unwrap(),
170 epoch_total_duration: register_int_gauge_with_registry!(
171 "epoch_total_duration",
172 "Total duration of the epoch",
173 registry
174 ).unwrap(),
175 epoch_transaction_count: register_int_gauge_with_registry!(
176 "epoch_transaction_count",
177 "Number of transactions in the epoch",
178 registry
179 ).unwrap(),
180 epoch_total_gas_reward: register_int_gauge_with_registry!(
181 "epoch_total_gas_reward",
182 "Total amount of gas rewards (i.e. computation gas cost) in the epoch",
183 registry
184 ).unwrap(),
185 epoch_pending_certs_processed_time_since_epoch_close_ms: register_int_gauge_with_registry!(
186 "epoch_pending_certs_processed_time_since_epoch_close_ms",
187 "Time interval from when epoch was closed to when all pending certificates are processed",
188 registry
189 ).unwrap(),
190 epoch_end_of_publish_quorum_time_since_epoch_close_ms: register_int_gauge_with_registry!(
191 "epoch_end_of_publish_quorum_time_since_epoch_close_ms",
192 "Time interval from when epoch was closed to when 2f+1 EndOfPublish messages are received",
193 registry
194 ).unwrap(),
195 epoch_last_checkpoint_created_time_since_epoch_close_ms: register_int_gauge_with_registry!(
196 "epoch_last_checkpoint_created_time_since_epoch_close_ms",
197 "Time interval from when epoch was closed to when the last checkpoint of the epoch is created",
198 registry
199 ).unwrap(),
200 epoch_reconfig_start_time_since_epoch_close_ms: register_int_gauge_with_registry!(
201 "epoch_reconfig_start_time_since_epoch_close_ms",
202 "Total time duration from when epoch was closed to when we begin to reconfigure the validator",
203 registry
204 ).unwrap(),
205 epoch_validator_halt_duration_ms: register_int_gauge_with_registry!(
206 "epoch_validator_halt_duration_ms",
207 "Total time duration when the validator was halted (i.e. epoch closed)",
208 registry
209 ).unwrap(),
210 epoch_first_checkpoint_created_time_since_epoch_begin_ms: register_int_gauge_with_registry!(
211 "epoch_first_checkpoint_created_time_since_epoch_begin_ms",
212 "Time interval from when the epoch opens at new epoch to the first checkpoint is created locally",
213 registry
214 ).unwrap(),
215 is_safe_mode: register_int_gauge_with_registry!(
216 "is_safe_mode",
217 "Whether we are running in safe mode",
218 registry,
219 ).unwrap(),
220 checkpoint_builder_advance_epoch_is_safe_mode: register_int_gauge_with_registry!(
221 "checkpoint_builder_advance_epoch_is_safe_mode",
222 "Whether the advance epoch execution leads to safe mode while building the last checkpoint",
223 registry,
224 ).unwrap(),
225 effective_buffer_stake: register_int_gauge_with_registry!(
226 "effective_buffer_stake",
227 "Buffer stake current in effect for this epoch",
228 registry,
229 ).unwrap(),
230 epoch_random_beacon_dkg_failed: register_int_gauge_with_registry!(
231 "epoch_random_beacon_dkg_failed",
232 "Set to 1 if the random beacon DKG protocol failed for the most recent epoch.",
233 registry
234 )
235 .unwrap(),
236 epoch_random_beacon_dkg_num_shares: register_int_gauge_with_registry!(
237 "epoch_random_beacon_dkg_num_shares",
238 "The number of shares held by this node after the random beacon DKG protocol completed",
239 registry
240 )
241 .unwrap(),
242 epoch_random_beacon_dkg_epoch_start_completion_time_ms: register_int_gauge_with_registry!(
243 "epoch_random_beacon_dkg_epoch_start_completion_time_ms",
244 "The amount of time taken from epoch start to completion of random beacon DKG protocol, for the most recent epoch",
245 registry
246 )
247 .unwrap(),
248 epoch_random_beacon_dkg_completion_time_ms: register_int_gauge_with_registry!(
249 "epoch_random_beacon_dkg_completion_time_ms",
250 "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",
251 registry
252 )
253 .unwrap(),
254 epoch_random_beacon_dkg_message_time_ms: register_int_gauge_with_registry!(
255 "epoch_random_beacon_dkg_message_time_ms",
256 "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",
257 registry
258 )
259 .unwrap(),
260 epoch_random_beacon_dkg_confirmation_time_ms: register_int_gauge_with_registry!(
261 "epoch_random_beacon_dkg_confirmation_time_ms",
262 "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",
263 registry
264 )
265 .unwrap(),
266 epoch_execution_time_observations_shared: register_int_counter_with_registry!(
267 "epoch_execution_time_observations_shared",
268 "The number of execution time observations messages shared by this node",
269 registry
270 )
271 .unwrap(),
272 epoch_execution_time_observations_sharing_reason: register_int_counter_vec_with_registry!(
273 "epoch_execution_time_observations_sharing_reason",
274 "The number of execution time observations messages intended to be shared by this node, annotated with reason",
275 &["reason"],
276 registry
277 )
278 .unwrap(),
279 epoch_execution_time_measurements_dropped: register_int_counter_with_registry!(
280 "epoch_execution_time_measurements_dropped",
281 "The number of execution time measurements dropped due to backpressure from the observer",
282 registry
283 )
284 .unwrap(),
285 epoch_execution_time_observations_dropped: register_int_counter_vec_with_registry!(
286 "epoch_execution_time_observations_dropped",
287 "The number of execution time observations dropped",
288 &["reason"],
289 registry
290 )
291 .unwrap(),
292 epoch_execution_time_observer_indebted_objects: register_int_gauge_with_registry!(
293 "epoch_execution_time_observer_indebted_objects",
294 "The number of cached indebted objects in the execution time observer",
295 registry
296 )
297 .unwrap(),
298 epoch_execution_time_observer_utilization_cache_size: register_int_gauge_with_registry!(
299 "epoch_execution_time_observer_utilization_cache_size",
300 "The number of objects tracked by the object utilization cache",
301 registry
302 )
303 .unwrap(),
304 epoch_execution_time_observer_overutilized_objects: register_int_gauge_with_registry!(
305 "epoch_execution_time_observer_overutilized_objects",
306 "The number of objects determined by the execution time observer to be overutilized. Note: this may overcount if objects are evicted from the cache before being computed as not-overutilized.",
307 registry
308 )
309 .unwrap(),
310 epoch_execution_time_observer_object_utilization: register_counter_vec_with_registry!(
311 "epoch_execution_time_observer_object_utilization",
312 "Per-object utilization for objects that were overutilized at least once at some point in their lifetime",
313 &["object_id"],
314 registry
315 )
316 .unwrap(),
317 epoch_execution_time_observer_tracked_object_utilization: register_counter_vec_with_registry!(
318 "epoch_execution_time_observer_tracked_object_utilization",
319 "Utilization of objects explicitly listed in the execution time observer config, labeled by full object ID and configured name",
320 &["object_id", "name"],
321 registry
322 )
323 .unwrap(),
324 epoch_execution_time_observations_loaded: register_int_gauge_with_registry!(
325 "epoch_execution_time_observations_loaded",
326 "The number of execution time observations loaded at start of epoch",
327 registry
328 )
329 .unwrap(),
330 consensus_quarantine_queue_size: register_int_gauge_with_registry!(
331 "consensus_quarantine_queue_size",
332 "The number of consensus output items in the quarantine",
333 registry
334 )
335 .unwrap(),
336 shared_object_assignments_size: register_int_gauge_with_registry!(
337 "shared_object_assignments_size",
338 "The number of shared object assignments in the quarantine",
339 registry
340 )
341 .unwrap(),
342 };
343 Arc::new(this)
344 }
345}