1use std::sync::Arc;
6
7use prometheus_filtered::{
8 IntCounter, IntGauge, MetricLevel, Registry, register_int_counter_with_registry,
9 register_int_gauge_with_registry,
10};
11
12pub struct EpochMetrics {
13 pub current_epoch: IntGauge,
16
17 pub current_voting_right: IntGauge,
20
21 pub epoch_total_duration: IntGauge,
25
26 pub epoch_checkpoint_count: IntGauge,
28
29 pub epoch_transaction_count: IntGauge,
31
32 pub epoch_total_gas_reward: IntGauge,
34
35 pub epoch_pending_certs_processed_time_since_epoch_close_ms: IntGauge,
51
52 pub epoch_end_of_publish_quorum_time_since_epoch_close_ms: IntGauge,
56
57 pub epoch_last_checkpoint_created_time_since_epoch_close_ms: IntGauge,
61
62 pub epoch_reconfig_start_time_since_epoch_close_ms: IntGauge,
67
68 pub epoch_validator_halt_duration_ms: IntGauge,
73
74 pub epoch_first_checkpoint_created_time_since_epoch_begin_ms: IntGauge,
81
82 pub is_safe_mode: IntGauge,
85
86 pub checkpoint_builder_advance_epoch_is_safe_mode: IntGauge,
91
92 pub effective_buffer_stake: IntGauge,
94
95 pub epoch_random_beacon_dkg_failed: IntGauge,
98
99 pub epoch_random_beacon_dkg_num_shares: IntGauge,
102
103 pub epoch_random_beacon_dkg_epoch_start_completion_time_ms: IntGauge,
106
107 pub epoch_random_beacon_dkg_completion_time_ms: IntGauge,
111
112 pub epoch_random_beacon_dkg_message_time_ms: IntGauge,
116
117 pub epoch_random_beacon_dkg_confirmation_time_ms: IntGauge,
121
122 pub consensus_quarantine_queue_size: IntGauge,
124
125 pub deny_rule_updates_injected: IntCounter,
128
129 pub deny_rule_update_transactions_injected: IntCounter,
132
133 pub deny_rule_removals_unlocked: IntGauge,
136
137 pub deny_rule_mirror_divergence: IntGauge,
140
141 pub deny_rule_update_execution_failures: IntCounter,
144}
145
146impl EpochMetrics {
147 pub fn new(registry: &Registry) -> Arc<Self> {
148 let this = Self {
149 current_epoch: register_int_gauge_with_registry!(
150 "current_epoch",
151 "Current epoch ID",
152 registry;
153 MetricLevel::Warn,
154 )
155 .unwrap(),
156 current_voting_right: register_int_gauge_with_registry!(
157 "current_voting_right",
158 "Current voting right of the validator",
159 registry;
160 MetricLevel::Warn,
161 )
162 .unwrap(),
163 epoch_checkpoint_count: register_int_gauge_with_registry!(
164 "epoch_checkpoint_count",
165 "Number of checkpoints in the epoch",
166 registry
167 ).unwrap(),
168 epoch_total_duration: register_int_gauge_with_registry!(
169 "epoch_total_duration",
170 "Total duration of the epoch",
171 registry;
172 MetricLevel::Warn,
173 ).unwrap(),
174 epoch_transaction_count: register_int_gauge_with_registry!(
175 "epoch_transaction_count",
176 "Number of transactions in the epoch",
177 registry
178 ).unwrap(),
179 epoch_total_gas_reward: register_int_gauge_with_registry!(
180 "epoch_total_gas_reward",
181 "Total amount of gas rewards (i.e. computation gas cost) in the epoch",
182 registry;
183 MetricLevel::Warn,
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 MetricLevel::Info,
220 ).unwrap(),
221 checkpoint_builder_advance_epoch_is_safe_mode: register_int_gauge_with_registry!(
222 "checkpoint_builder_advance_epoch_is_safe_mode",
223 "Whether the advance epoch execution leads to safe mode while building the last checkpoint",
224 registry,
225 ).unwrap(),
226 effective_buffer_stake: register_int_gauge_with_registry!(
227 "effective_buffer_stake",
228 "Buffer stake current in effect for this epoch",
229 registry,
230 ).unwrap(),
231 epoch_random_beacon_dkg_failed: register_int_gauge_with_registry!(
232 "epoch_random_beacon_dkg_failed",
233 "Set to 1 if the random beacon DKG protocol failed for the most recent epoch.",
234 registry
235 )
236 .unwrap(),
237 epoch_random_beacon_dkg_num_shares: register_int_gauge_with_registry!(
238 "epoch_random_beacon_dkg_num_shares",
239 "The number of shares held by this node after the random beacon DKG protocol completed",
240 registry
241 )
242 .unwrap(),
243 epoch_random_beacon_dkg_epoch_start_completion_time_ms: register_int_gauge_with_registry!(
244 "epoch_random_beacon_dkg_epoch_start_completion_time_ms",
245 "The amount of time taken from epoch start to completion of random beacon DKG protocol, for the most recent epoch",
246 registry
247 )
248 .unwrap(),
249 epoch_random_beacon_dkg_completion_time_ms: register_int_gauge_with_registry!(
250 "epoch_random_beacon_dkg_completion_time_ms",
251 "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",
252 registry
253 )
254 .unwrap(),
255 epoch_random_beacon_dkg_message_time_ms: register_int_gauge_with_registry!(
256 "epoch_random_beacon_dkg_message_time_ms",
257 "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",
258 registry
259 )
260 .unwrap(),
261 epoch_random_beacon_dkg_confirmation_time_ms: register_int_gauge_with_registry!(
262 "epoch_random_beacon_dkg_confirmation_time_ms",
263 "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",
264 registry
265 )
266 .unwrap(),
267 consensus_quarantine_queue_size: register_int_gauge_with_registry!(
268 "consensus_quarantine_queue_size",
269 "The number of consensus output items in the quarantine",
270 registry;
271 MetricLevel::Warn,
272 )
273 .unwrap(),
274 deny_rule_updates_injected: register_int_counter_with_registry!(
275 "deny_rule_updates_injected",
276 "The number of consensus commits that injected deny-rule update transactions",
277 registry
278 )
279 .unwrap(),
280 deny_rule_update_transactions_injected: register_int_counter_with_registry!(
281 "deny_rule_update_transactions_injected",
282 "The number of injected deny-rule update transactions",
283 registry
284 )
285 .unwrap(),
286 deny_rule_removals_unlocked: register_int_gauge_with_registry!(
287 "deny_rule_removals_unlocked",
288 "Whether deny-rule removals are currently unlocked",
289 registry
290 )
291 .unwrap(),
292 deny_rule_mirror_divergence: register_int_gauge_with_registry!(
293 "deny_rule_mirror_divergence",
294 "Set to 1 when the TransactionDenyRules object diverged from the mirrored state \
295 at an epoch boundary",
296 registry
297 )
298 .unwrap(),
299 deny_rule_update_execution_failures: register_int_counter_with_registry!(
300 "deny_rule_update_execution_failures",
301 "The number of injected deny-rule update transactions whose execution failed",
302 registry
303 )
304 .unwrap(),
305 };
306 Arc::new(this)
307 }
308}