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 pub consensus_quarantine_queue_size: IntGauge,
121
122 pub shared_object_assignments_size: IntGauge,
124}
125
126impl EpochMetrics {
127 pub fn new(registry: &Registry) -> Arc<Self> {
128 let this = Self {
129 current_epoch: register_int_gauge_with_registry!(
130 "current_epoch",
131 "Current epoch ID",
132 registry
133 )
134 .unwrap(),
135 current_voting_right: register_int_gauge_with_registry!(
136 "current_voting_right",
137 "Current voting right of the validator",
138 registry
139 )
140 .unwrap(),
141 epoch_checkpoint_count: register_int_gauge_with_registry!(
142 "epoch_checkpoint_count",
143 "Number of checkpoints in the epoch",
144 registry
145 ).unwrap(),
146 epoch_total_duration: register_int_gauge_with_registry!(
147 "epoch_total_duration",
148 "Total duration of the epoch",
149 registry
150 ).unwrap(),
151 epoch_transaction_count: register_int_gauge_with_registry!(
152 "epoch_transaction_count",
153 "Number of transactions in the epoch",
154 registry
155 ).unwrap(),
156 epoch_total_gas_reward: register_int_gauge_with_registry!(
157 "epoch_total_gas_reward",
158 "Total amount of gas rewards (i.e. computation gas cost) in the epoch",
159 registry
160 ).unwrap(),
161 epoch_pending_certs_processed_time_since_epoch_close_ms: register_int_gauge_with_registry!(
162 "epoch_pending_certs_processed_time_since_epoch_close_ms",
163 "Time interval from when epoch was closed to when all pending certificates are processed",
164 registry
165 ).unwrap(),
166 epoch_end_of_publish_quorum_time_since_epoch_close_ms: register_int_gauge_with_registry!(
167 "epoch_end_of_publish_quorum_time_since_epoch_close_ms",
168 "Time interval from when epoch was closed to when 2f+1 EndOfPublish messages are received",
169 registry
170 ).unwrap(),
171 epoch_last_checkpoint_created_time_since_epoch_close_ms: register_int_gauge_with_registry!(
172 "epoch_last_checkpoint_created_time_since_epoch_close_ms",
173 "Time interval from when epoch was closed to when the last checkpoint of the epoch is created",
174 registry
175 ).unwrap(),
176 epoch_reconfig_start_time_since_epoch_close_ms: register_int_gauge_with_registry!(
177 "epoch_reconfig_start_time_since_epoch_close_ms",
178 "Total time duration from when epoch was closed to when we begin to reconfigure the validator",
179 registry
180 ).unwrap(),
181 epoch_validator_halt_duration_ms: register_int_gauge_with_registry!(
182 "epoch_validator_halt_duration_ms",
183 "Total time duration when the validator was halted (i.e. epoch closed)",
184 registry
185 ).unwrap(),
186 epoch_first_checkpoint_created_time_since_epoch_begin_ms: register_int_gauge_with_registry!(
187 "epoch_first_checkpoint_created_time_since_epoch_begin_ms",
188 "Time interval from when the epoch opens at new epoch to the first checkpoint is created locally",
189 registry
190 ).unwrap(),
191 is_safe_mode: register_int_gauge_with_registry!(
192 "is_safe_mode",
193 "Whether we are running in safe mode",
194 registry,
195 ).unwrap(),
196 checkpoint_builder_advance_epoch_is_safe_mode: register_int_gauge_with_registry!(
197 "checkpoint_builder_advance_epoch_is_safe_mode",
198 "Whether the advance epoch execution leads to safe mode while building the last checkpoint",
199 registry,
200 ).unwrap(),
201 effective_buffer_stake: register_int_gauge_with_registry!(
202 "effective_buffer_stake",
203 "Buffer stake current in effect for this epoch",
204 registry,
205 ).unwrap(),
206 epoch_random_beacon_dkg_failed: register_int_gauge_with_registry!(
207 "epoch_random_beacon_dkg_failed",
208 "Set to 1 if the random beacon DKG protocol failed for the most recent epoch.",
209 registry
210 )
211 .unwrap(),
212 epoch_random_beacon_dkg_num_shares: register_int_gauge_with_registry!(
213 "epoch_random_beacon_dkg_num_shares",
214 "The number of shares held by this node after the random beacon DKG protocol completed",
215 registry
216 )
217 .unwrap(),
218 epoch_random_beacon_dkg_epoch_start_completion_time_ms: register_int_gauge_with_registry!(
219 "epoch_random_beacon_dkg_epoch_start_completion_time_ms",
220 "The amount of time taken from epoch start to completion of random beacon DKG protocol, for the most recent epoch",
221 registry
222 )
223 .unwrap(),
224 epoch_random_beacon_dkg_completion_time_ms: register_int_gauge_with_registry!(
225 "epoch_random_beacon_dkg_completion_time_ms",
226 "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",
227 registry
228 )
229 .unwrap(),
230 epoch_random_beacon_dkg_message_time_ms: register_int_gauge_with_registry!(
231 "epoch_random_beacon_dkg_message_time_ms",
232 "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",
233 registry
234 )
235 .unwrap(),
236 epoch_random_beacon_dkg_confirmation_time_ms: register_int_gauge_with_registry!(
237 "epoch_random_beacon_dkg_confirmation_time_ms",
238 "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",
239 registry
240 )
241 .unwrap(),
242 consensus_quarantine_queue_size: register_int_gauge_with_registry!(
243 "consensus_quarantine_queue_size",
244 "The number of consensus output items in the quarantine",
245 registry
246 )
247 .unwrap(),
248 shared_object_assignments_size: register_int_gauge_with_registry!(
249 "shared_object_assignments_size",
250 "The number of shared object assignments in the quarantine",
251 registry
252 )
253 .unwrap(),
254 };
255 Arc::new(this)
256 }
257}