1use std::sync::Arc;
5
6use prometheus::{
7 Histogram, HistogramVec, IntCounter, IntCounterVec, IntGauge, IntGaugeVec, Registry,
8 exponential_buckets, register_histogram_vec_with_registry, register_histogram_with_registry,
9 register_int_counter_vec_with_registry, register_int_counter_with_registry,
10 register_int_gauge_vec_with_registry, register_int_gauge_with_registry,
11};
12
13use crate::network::metrics::NetworkMetrics;
14
15const FINE_GRAINED_LATENCY_SEC_BUCKETS: &[f64] = &[
17 0.000_001, 0.000_050, 0.000_100, 0.000_500, 0.001, 0.005, 0.01, 0.05, 0.1, 0.15, 0.2, 0.25,
18 0.3, 0.35, 0.4, 0.45, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.2, 1.4, 1.6, 1.8, 2.0, 2.5, 3.0, 3.5,
19 4.0, 4.5, 5.0, 5.5, 6.0, 6.5, 7.0, 7.5, 8.0, 8.5, 9.0, 9.5, 10., 20., 30., 60., 120.,
20];
21
22const NUM_BUCKETS: &[f64] = &[
23 1.0,
24 2.0,
25 4.0,
26 8.0,
27 10.0,
28 20.0,
29 40.0,
30 80.0,
31 100.0,
32 150.0,
33 200.0,
34 400.0,
35 800.0,
36 1000.0,
37 2000.0,
38 3000.0,
39 5000.0,
40 10000.0,
41 20000.0,
42 30000.0,
43 50000.0,
44 100_000.0,
45 200_000.0,
46 300_000.0,
47 500_000.0,
48 1_000_000.0,
49];
50
51const LATENCY_SEC_BUCKETS: &[f64] = &[
52 0.001, 0.005, 0.01, 0.05, 0.1, 0.15, 0.2, 0.25, 0.3, 0.35, 0.4, 0.45, 0.5, 0.6, 0.7, 0.8, 0.9,
53 1.0, 1.2, 1.4, 1.6, 1.8, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0, 5.5, 6.0, 6.5, 7.0, 7.5, 8.0, 8.5,
54 9.0, 9.5, 10., 12.5, 15., 17.5, 20., 25., 30., 60., 90., 120., 180., 300.,
55];
56
57const SIZE_BUCKETS: &[f64] = &[
58 100.,
59 400.,
60 800.,
61 1_000.,
62 2_000.,
63 5_000.,
64 10_000.,
65 20_000.,
66 50_000.,
67 100_000.,
68 200_000.0,
69 300_000.0,
70 400_000.0,
71 500_000.0,
72 1_000_000.0,
73 2_000_000.0,
74 3_000_000.0,
75 5_000_000.0,
76 10_000_000.0,
77]; const ROUND_DELAY_BUCKETS: &[f64] = &[0.0, 0.5, 1.0, 2.0, 3.0, 4.0];
81
82pub struct Metrics {
83 pub(crate) node_metrics: NodeMetrics,
84 pub(crate) network_metrics: NetworkMetrics,
85}
86
87pub(crate) fn initialise_metrics(registry: Registry) -> Arc<Metrics> {
88 let node_metrics = NodeMetrics::new(®istry);
89 let network_metrics = NetworkMetrics::new(®istry);
90
91 Arc::new(Metrics {
92 node_metrics,
93 network_metrics,
94 })
95}
96
97pub(crate) fn test_metrics() -> Arc<Metrics> {
98 initialise_metrics(Registry::new())
99}
100
101pub(crate) struct NodeMetrics {
102 pub(crate) authority_index: IntGaugeVec,
103 pub(crate) protocol_version: IntGauge,
104 pub(crate) block_commit_latency: Histogram,
105 pub(crate) proposed_blocks: IntCounterVec,
106 pub(crate) proposed_block_size: Histogram,
107 pub(crate) proposed_block_transactions: Histogram,
108 pub(crate) proposed_block_ancestors: Histogram,
109 pub(crate) proposed_block_ancestors_depth: HistogramVec,
110 pub(crate) proposed_block_ancestors_timestamp_drift_ms: IntCounterVec,
111 pub(crate) highest_verified_authority_round: IntGaugeVec,
112 pub(crate) lowest_verified_authority_round: IntGaugeVec,
113 pub(crate) block_proposal_interval: Histogram,
114 pub(crate) block_proposal_leader_wait_ms: IntCounterVec,
115 pub(crate) block_proposal_leader_wait_count: IntCounterVec,
116 pub(crate) block_timestamp_drift_ms: IntCounterVec,
117 pub(crate) blocks_per_commit_count: Histogram,
118 pub(crate) blocks_pruned_on_commit: IntCounterVec,
119 pub(crate) commit_observer_last_recovered_commit_index: IntGauge,
120 pub(crate) core_add_blocks_batch_size: Histogram,
121 pub(crate) core_check_block_refs_batch_size: Histogram,
122 pub(crate) core_lock_dequeued: IntCounter,
123 pub(crate) core_lock_enqueued: IntCounter,
124 pub(crate) core_skipped_proposals: IntCounterVec,
125 pub(crate) handler_received_block_missing_ancestors: IntCounterVec,
126 pub(crate) highest_accepted_authority_round: IntGaugeVec,
127 pub(crate) highest_accepted_round: IntGauge,
128 pub(crate) accepted_block_time_drift_ms: IntCounterVec,
129 pub(crate) accepted_blocks: IntCounterVec,
130 pub(crate) dag_state_recent_blocks: IntGauge,
131 pub(crate) dag_state_recent_refs: IntGauge,
132 pub(crate) dag_state_store_read_count: IntCounterVec,
133 pub(crate) dag_state_store_write_count: IntCounter,
134 pub(crate) fetch_blocks_scheduler_inflight: IntGauge,
135 pub(crate) synchronizer_fetched_blocks_by_peer: IntCounterVec,
136 pub(crate) synchronizer_missing_blocks_by_authority: IntCounterVec,
137 pub(crate) synchronizer_current_missing_blocks_by_authority: IntGaugeVec,
138 pub(crate) synchronizer_fetched_blocks_by_authority: IntCounterVec,
139 pub(crate) synchronizer_fetch_failures: IntCounterVec,
140 pub(crate) synchronizer_skipped_fetch_requests: IntCounterVec,
141 pub(crate) synchronizer_process_fetched_failures: IntCounterVec,
142 pub(crate) synchronizer_periodic_sync_decision: IntCounterVec,
143 pub(crate) network_received_excluded_ancestors_from_authority: IntCounterVec,
144 pub(crate) network_excluded_ancestors_sent_to_fetch: IntCounterVec,
145 pub(crate) network_excluded_ancestors_count_by_authority: IntCounterVec,
146 pub(crate) invalid_blocks: IntCounterVec,
147 pub(crate) rejected_blocks: IntCounterVec,
148 pub(crate) subscribed_blocks: IntCounterVec,
149 pub(crate) observer_subscribed_blocks_batch_size: Histogram,
150 pub(crate) verified_blocks: IntCounterVec,
151 pub(crate) committed_leaders_total: IntCounterVec,
152 pub(crate) last_committed_authority_round: IntGaugeVec,
153 pub(crate) last_committed_leader_round: IntGauge,
154 pub(crate) last_commit_index: IntGauge,
155 pub(crate) last_commit_time_diff: Histogram,
156 pub(crate) last_known_own_block_round: IntGauge,
157 pub(crate) sync_last_known_own_block_retries: IntCounter,
158 pub(crate) commit_round_advancement_interval: Histogram,
159 pub(crate) last_decided_leader_round: IntGauge,
160 pub(crate) leader_timeout_total: IntCounterVec,
161 pub(crate) smart_selection_wait: IntCounter,
162 pub(crate) ancestor_state_change_by_authority: IntCounterVec,
163 pub(crate) excluded_proposal_ancestors_count_by_authority: IntCounterVec,
164 pub(crate) included_excluded_proposal_ancestors_count_by_authority: IntCounterVec,
165 pub(crate) missing_blocks_total: IntCounter,
166 pub(crate) missing_blocks_after_fetch_total: IntCounter,
167 pub(crate) num_of_bad_nodes: IntGauge,
168 pub(crate) quorum_receive_latency: Histogram,
169 pub(crate) block_receive_delay: IntCounterVec,
170 pub(crate) reputation_scores: IntGaugeVec,
171 pub(crate) scope_processing_time: HistogramVec,
172 pub(crate) sub_dags_per_commit_count: Histogram,
173 pub(crate) block_suspensions: IntCounterVec,
174 pub(crate) block_unsuspensions: IntCounterVec,
175 pub(crate) suspended_block_time: HistogramVec,
176 pub(crate) block_manager_suspended_blocks: IntGauge,
177 pub(crate) block_manager_missing_ancestors: IntGauge,
178 pub(crate) block_manager_missing_blocks: IntGauge,
179 pub(crate) block_manager_missing_blocks_by_authority: IntCounterVec,
180 pub(crate) block_manager_missing_ancestors_by_authority: IntCounterVec,
181 pub(crate) block_manager_gced_blocks: IntCounterVec,
182 pub(crate) block_manager_gc_unsuspended_blocks: IntCounterVec,
183 pub(crate) block_manager_skipped_blocks: IntCounterVec,
184 pub(crate) threshold_clock_round: IntGauge,
185 pub(crate) subscriber_connection_attempts: IntCounterVec,
186 pub(crate) subscribed_to: IntGaugeVec,
187 pub(crate) subscribed_by: IntGaugeVec,
188 pub(crate) commit_sync_inflight_fetches: IntGauge,
189 pub(crate) commit_sync_pending_fetches: IntGauge,
190 pub(crate) commit_sync_fetch_commits_handler_uncertified_skipped: IntCounter,
191 pub(crate) commit_sync_fetched_commits: IntCounter,
192 pub(crate) commit_sync_fetched_blocks: IntCounter,
193 pub(crate) commit_sync_total_fetched_blocks_size: IntCounter,
194 pub(crate) commit_sync_quorum_index: IntGauge,
195 pub(crate) commit_sync_highest_synced_index: IntGauge,
196 pub(crate) commit_sync_highest_fetched_index: IntGauge,
197 pub(crate) commit_sync_local_index: IntGauge,
198 pub(crate) commit_sync_gap_on_processing: IntCounter,
199 pub(crate) commit_sync_fetch_loop_latency: Histogram,
200 pub(crate) commit_sync_fetch_once_latency: Histogram,
201 pub(crate) commit_sync_fetch_once_errors: IntCounterVec,
202 pub(crate) commit_sync_fetch_missing_blocks: IntCounterVec,
203 pub(crate) round_tracker_received_quorum_round_gaps: IntGaugeVec,
204 pub(crate) round_tracker_accepted_quorum_round_gaps: IntGaugeVec,
205 pub(crate) round_tracker_low_received_quorum_round: IntGaugeVec,
206 pub(crate) round_tracker_low_accepted_quorum_round: IntGaugeVec,
207 pub(crate) round_tracker_current_received_round_gaps: IntGaugeVec,
208 pub(crate) round_tracker_current_accepted_round_gaps: IntGaugeVec,
209 pub(crate) round_tracker_propagation_delays: Histogram,
210 pub(crate) round_tracker_last_propagation_delay: IntGauge,
211 pub(crate) round_prober_request_errors: IntCounterVec,
212 pub(crate) certifier_gc_round: IntGauge,
213 pub(crate) certifier_own_reject_votes: IntCounterVec,
214 pub(crate) finalizer_buffered_commits: IntGauge,
215 pub(crate) finalizer_round_delay: Histogram,
216 pub(crate) finalizer_transaction_status: IntCounterVec,
217 pub(crate) finalizer_reject_votes: IntCounterVec,
218 pub(crate) finalizer_output_commits: IntCounterVec,
219 pub(crate) finalizer_skipped_voting_blocks: IntCounterVec,
220 pub(crate) uptime: Histogram,
221}
222
223impl NodeMetrics {
224 pub(crate) fn new(registry: &Registry) -> Self {
225 Self {
226 authority_index: register_int_gauge_vec_with_registry!(
227 "authority_index",
228 "The index of the authority",
229 &["name"],
230 registry,
231 ).unwrap(),
232 protocol_version: register_int_gauge_with_registry!(
233 "protocol_version",
234 "The protocol version used in this epoch",
235 registry,
236 ).unwrap(),
237 block_commit_latency: register_histogram_with_registry!(
238 "block_commit_latency",
239 "The time taken between block creation and block commit.",
240 LATENCY_SEC_BUCKETS.to_vec(),
241 registry,
242 ).unwrap(),
243 proposed_blocks: register_int_counter_vec_with_registry!(
244 "proposed_blocks",
245 "Total number of proposed blocks. If force is true then this block has been created forcefully via a leader timeout event.",
246 &["force"],
247 registry,
248 ).unwrap(),
249 proposed_block_size: register_histogram_with_registry!(
250 "proposed_block_size",
251 "The size (in bytes) of proposed blocks",
252 SIZE_BUCKETS.to_vec(),
253 registry
254 ).unwrap(),
255 proposed_block_transactions: register_histogram_with_registry!(
256 "proposed_block_transactions",
257 "# of transactions contained in proposed blocks",
258 NUM_BUCKETS.to_vec(),
259 registry
260 ).unwrap(),
261 proposed_block_ancestors: register_histogram_with_registry!(
262 "proposed_block_ancestors",
263 "Number of ancestors in proposed blocks",
264 exponential_buckets(1.0, 1.4, 20).unwrap(),
265 registry,
266 ).unwrap(),
267 proposed_block_ancestors_timestamp_drift_ms: register_int_counter_vec_with_registry!(
268 "proposed_block_ancestors_timestamp_drift_ms",
269 "The drift in ms of ancestors' timestamps included in newly proposed blocks",
270 &["authority"],
271 registry,
272 ).unwrap(),
273 proposed_block_ancestors_depth: register_histogram_vec_with_registry!(
274 "proposed_block_ancestors_depth",
275 "The depth in rounds of ancestors included in newly proposed blocks",
276 &["authority"],
277 exponential_buckets(1.0, 2.0, 14).unwrap(),
278 registry,
279 ).unwrap(),
280 highest_verified_authority_round: register_int_gauge_vec_with_registry!(
281 "highest_verified_authority_round",
282 "The highest round of verified block for the corresponding authority",
283 &["authority"],
284 registry,
285 ).unwrap(),
286 lowest_verified_authority_round: register_int_gauge_vec_with_registry!(
287 "lowest_verified_authority_round",
288 "The lowest round of verified block for the corresponding authority",
289 &["authority"],
290 registry,
291 ).unwrap(),
292 block_proposal_interval: register_histogram_with_registry!(
293 "block_proposal_interval",
294 "Intervals (in secs) between block proposals.",
295 FINE_GRAINED_LATENCY_SEC_BUCKETS.to_vec(),
296 registry,
297 ).unwrap(),
298 block_proposal_leader_wait_ms: register_int_counter_vec_with_registry!(
299 "block_proposal_leader_wait_ms",
300 "Total time in ms spent waiting for a leader when proposing blocks.",
301 &["authority"],
302 registry,
303 ).unwrap(),
304 block_proposal_leader_wait_count: register_int_counter_vec_with_registry!(
305 "block_proposal_leader_wait_count",
306 "Total times waiting for a leader when proposing blocks.",
307 &["authority"],
308 registry,
309 ).unwrap(),
310 block_timestamp_drift_ms: register_int_counter_vec_with_registry!(
311 "block_timestamp_drift_ms",
312 "The clock drift time between a received block and the current node's time.",
313 &["authority", "source"],
314 registry,
315 ).unwrap(),
316 blocks_per_commit_count: register_histogram_with_registry!(
317 "blocks_per_commit_count",
318 "The number of blocks per commit.",
319 NUM_BUCKETS.to_vec(),
320 registry,
321 ).unwrap(),
322 blocks_pruned_on_commit: register_int_counter_vec_with_registry!(
323 "blocks_pruned_on_commit",
324 "Number of blocks that got pruned due to garbage collection during a commit. This is not an accurate metric and measures the pruned blocks on the edge of the commit.",
325 &["authority", "commit_status"],
326 registry,
327 ).unwrap(),
328 commit_observer_last_recovered_commit_index: register_int_gauge_with_registry!(
329 "commit_observer_last_recovered_commit_index",
330 "The last commit index recovered by the commit observer",
331 registry,
332 ).unwrap(),
333 core_add_blocks_batch_size: register_histogram_with_registry!(
334 "core_add_blocks_batch_size",
335 "The number of blocks received from Core for processing on a single batch",
336 NUM_BUCKETS.to_vec(),
337 registry,
338 ).unwrap(),
339 core_check_block_refs_batch_size: register_histogram_with_registry!(
340 "core_check_block_refs_batch_size",
341 "The number of excluded blocks received from Core for search on a single batch",
342 NUM_BUCKETS.to_vec(),
343 registry,
344 ).unwrap(),
345 core_lock_dequeued: register_int_counter_with_registry!(
346 "core_lock_dequeued",
347 "Number of dequeued core requests",
348 registry,
349 ).unwrap(),
350 core_lock_enqueued: register_int_counter_with_registry!(
351 "core_lock_enqueued",
352 "Number of enqueued core requests",
353 registry,
354 ).unwrap(),
355 core_skipped_proposals: register_int_counter_vec_with_registry!(
356 "core_skipped_proposals",
357 "Number of proposals skipped in the Core, per reason",
358 &["reason"],
359 registry,
360 ).unwrap(),
361 handler_received_block_missing_ancestors: register_int_counter_vec_with_registry!(
362 "handler_received_block_missing_ancestors",
363 "Number of missing ancestors in blocks received in the handler, separated by peer",
364 &["authority"],
365 registry,
366 ).unwrap(),
367 highest_accepted_authority_round: register_int_gauge_vec_with_registry!(
368 "highest_accepted_authority_round",
369 "The highest round where a block has been accepted per authority. Resets on restart.",
370 &["authority"],
371 registry,
372 ).unwrap(),
373 highest_accepted_round: register_int_gauge_with_registry!(
374 "highest_accepted_round",
375 "The highest round where a block has been accepted. Resets on restart.",
376 registry,
377 ).unwrap(),
378 accepted_block_time_drift_ms: register_int_counter_vec_with_registry!(
379 "accepted_block_time_drift_ms",
380 "The time drift in ms of an accepted block compared to local time",
381 &["authority"],
382 registry,
383 ).unwrap(),
384 accepted_blocks: register_int_counter_vec_with_registry!(
385 "accepted_blocks",
386 "Number of accepted blocks by source (own, others)",
387 &["source"],
388 registry,
389 ).unwrap(),
390 dag_state_recent_blocks: register_int_gauge_with_registry!(
391 "dag_state_recent_blocks",
392 "Number of recent blocks cached in the DagState",
393 registry,
394 ).unwrap(),
395 dag_state_recent_refs: register_int_gauge_with_registry!(
396 "dag_state_recent_refs",
397 "Number of recent refs cached in the DagState",
398 registry,
399 ).unwrap(),
400 dag_state_store_read_count: register_int_counter_vec_with_registry!(
401 "dag_state_store_read_count",
402 "Number of times DagState needs to read from store per operation type",
403 &["type"],
404 registry,
405 ).unwrap(),
406 dag_state_store_write_count: register_int_counter_with_registry!(
407 "dag_state_store_write_count",
408 "Number of times DagState needs to write to store",
409 registry,
410 ).unwrap(),
411 fetch_blocks_scheduler_inflight: register_int_gauge_with_registry!(
412 "fetch_blocks_scheduler_inflight",
413 "Designates whether the synchronizer scheduler task to fetch blocks is currently running",
414 registry,
415 ).unwrap(),
416 synchronizer_fetched_blocks_by_peer: register_int_counter_vec_with_registry!(
417 "synchronizer_fetched_blocks_by_peer",
418 "Number of fetched blocks per peer authority via the synchronizer and also by block authority",
419 &["peer", "type"],
420 registry,
421 ).unwrap(),
422 synchronizer_missing_blocks_by_authority: register_int_counter_vec_with_registry!(
423 "synchronizer_missing_blocks_by_authority",
424 "Number of missing blocks per block author, as observed by the synchronizer during periodic sync.",
425 &["authority"],
426 registry,
427 ).unwrap(),
428 synchronizer_current_missing_blocks_by_authority: register_int_gauge_vec_with_registry!(
429 "synchronizer_current_missing_blocks_by_authority",
430 "Current number of missing blocks per block author, as observed by the synchronizer during periodic sync.",
431 &["authority"],
432 registry,
433 ).unwrap(),
434 synchronizer_fetched_blocks_by_authority: register_int_counter_vec_with_registry!(
435 "synchronizer_fetched_blocks_by_authority",
436 "Number of fetched blocks per block author via the synchronizer",
437 &["authority", "type"],
438 registry,
439 ).unwrap(),
440 synchronizer_fetch_failures: register_int_counter_vec_with_registry!(
441 "synchronizer_fetch_failures",
442 "Number of fetch failures against each peer",
443 &["peer", "type"],
444 registry,
445 ).unwrap(),
446 synchronizer_skipped_fetch_requests: register_int_counter_vec_with_registry!(
447 "synchronizer_skipped_fetch_requests",
448 "Number of fetch requests skipped against each peer, because the peer is saturated",
449 &["peer"],
450 registry,
451 ).unwrap(),
452 synchronizer_process_fetched_failures: register_int_counter_vec_with_registry!(
453 "synchronizer_process_fetched_failures",
454 "Number of failures for processing fetched blocks against each peer",
455 &["peer", "type"],
456 registry,
457 ).unwrap(),
458 synchronizer_periodic_sync_decision: register_int_counter_vec_with_registry!(
459 "synchronizer_periodic_sync_decision",
460 "Decision to run periodic sync",
461 &["decision", "reason"],
462 registry,
463 ).unwrap(),
464 network_received_excluded_ancestors_from_authority: register_int_counter_vec_with_registry!(
465 "network_received_excluded_ancestors_from_authority",
466 "Number of excluded ancestors received from each authority.",
467 &["authority"],
468 registry,
469 ).unwrap(),
470 network_excluded_ancestors_count_by_authority: register_int_counter_vec_with_registry!(
471 "network_excluded_ancestors_count_by_authority",
472 "Total number of excluded ancestors per authority.",
473 &["authority"],
474 registry,
475 ).unwrap(),
476 network_excluded_ancestors_sent_to_fetch: register_int_counter_vec_with_registry!(
477 "network_excluded_ancestors_sent_to_fetch",
478 "Number of excluded ancestors sent to fetch.",
479 &["authority"],
480 registry,
481 ).unwrap(),
482 last_known_own_block_round: register_int_gauge_with_registry!(
483 "last_known_own_block_round",
484 "The highest round of our own block as this has been synced from peers during an amnesia recovery",
485 registry,
486 ).unwrap(),
487 sync_last_known_own_block_retries: register_int_counter_with_registry!(
488 "sync_last_known_own_block_retries",
489 "Number of times this node tried to fetch the last own block from peers",
490 registry,
491 ).unwrap(),
492 invalid_blocks: register_int_counter_vec_with_registry!(
493 "invalid_blocks",
494 "Number of invalid blocks per peer authority",
495 &["authority", "source", "error"],
496 registry,
497 ).unwrap(),
498 rejected_blocks: register_int_counter_vec_with_registry!(
499 "rejected_blocks",
500 "Number of blocks rejected before verifications",
501 &["reason"],
502 registry,
503 ).unwrap(),
504 subscribed_blocks: register_int_counter_vec_with_registry!(
505 "subscribed_blocks",
506 "Number of blocks received from each peer before verification",
507 &["authority"],
508 registry,
509 ).unwrap(),
510 observer_subscribed_blocks_batch_size: register_histogram_with_registry!(
511 "observer_subscribed_blocks_batch_size",
512 "The number of blocks received from a peer before verification in a single batch",
513 NUM_BUCKETS.to_vec(),
514 registry,
515 ).unwrap(),
516 verified_blocks: register_int_counter_vec_with_registry!(
517 "verified_blocks",
518 "Number of blocks received from each peer that are verified",
519 &["authority"],
520 registry,
521 ).unwrap(),
522 committed_leaders_total: register_int_counter_vec_with_registry!(
523 "committed_leaders_total",
524 "Total number of (direct or indirect) committed leaders per authority",
525 &["authority", "commit_type"],
526 registry,
527 ).unwrap(),
528 last_committed_authority_round: register_int_gauge_vec_with_registry!(
529 "last_committed_authority_round",
530 "The last round committed by authority.",
531 &["authority"],
532 registry,
533 ).unwrap(),
534 last_committed_leader_round: register_int_gauge_with_registry!(
535 "last_committed_leader_round",
536 "The last round where a leader was committed to store and sent to commit consumer.",
537 registry,
538 ).unwrap(),
539 last_commit_index: register_int_gauge_with_registry!(
540 "last_commit_index",
541 "Index of the last commit.",
542 registry,
543 ).unwrap(),
544 last_commit_time_diff: register_histogram_with_registry!(
545 "last_commit_time_diff",
546 "The time diff between the last commit and previous one.",
547 LATENCY_SEC_BUCKETS.to_vec(),
548 registry,
549 ).unwrap(),
550 commit_round_advancement_interval: register_histogram_with_registry!(
551 "commit_round_advancement_interval",
552 "Intervals (in secs) between commit round advancements.",
553 FINE_GRAINED_LATENCY_SEC_BUCKETS.to_vec(),
554 registry,
555 ).unwrap(),
556 last_decided_leader_round: register_int_gauge_with_registry!(
557 "last_decided_leader_round",
558 "The last round where a commit decision was made.",
559 registry,
560 ).unwrap(),
561 leader_timeout_total: register_int_counter_vec_with_registry!(
562 "leader_timeout_total",
563 "Total number of leader timeouts, either when the min round time has passed, or max leader timeout",
564 &["timeout_type"],
565 registry,
566 ).unwrap(),
567 smart_selection_wait: register_int_counter_with_registry!(
568 "smart_selection_wait",
569 "Number of times we waited for smart ancestor selection.",
570 registry,
571 ).unwrap(),
572 ancestor_state_change_by_authority: register_int_counter_vec_with_registry!(
573 "ancestor_state_change_by_authority",
574 "The total number of times an ancestor state changed to EXCLUDE or INCLUDE.",
575 &["authority", "state"],
576 registry,
577 ).unwrap(),
578 excluded_proposal_ancestors_count_by_authority: register_int_counter_vec_with_registry!(
579 "excluded_proposal_ancestors_count_by_authority",
580 "Total number of excluded ancestors per authority during proposal.",
581 &["authority"],
582 registry,
583 ).unwrap(),
584 included_excluded_proposal_ancestors_count_by_authority: register_int_counter_vec_with_registry!(
585 "included_excluded_proposal_ancestors_count_by_authority",
586 "Total number of ancestors per authority with 'excluded' status that got included in proposal. Either weak or strong type.",
587 &["authority", "type"],
588 registry,
589 ).unwrap(),
590 missing_blocks_total: register_int_counter_with_registry!(
591 "missing_blocks_total",
592 "Total cumulative number of missing blocks",
593 registry,
594 ).unwrap(),
595 missing_blocks_after_fetch_total: register_int_counter_with_registry!(
596 "missing_blocks_after_fetch_total",
597 "Total number of missing blocks after fetching blocks from peer",
598 registry,
599 ).unwrap(),
600 num_of_bad_nodes: register_int_gauge_with_registry!(
601 "num_of_bad_nodes",
602 "The number of bad nodes in the new leader schedule",
603 registry
604 ).unwrap(),
605 quorum_receive_latency: register_histogram_with_registry!(
606 "quorum_receive_latency",
607 "The time it took to receive a new round quorum of blocks",
608 registry
609 ).unwrap(),
610 block_receive_delay: register_int_counter_vec_with_registry!(
611 "block_receive_delay",
612 "Total delay from the start of the round to receiving the block, in milliseconds per authority",
613 &["authority"],
614 registry,
615 ).unwrap(),
616 reputation_scores: register_int_gauge_vec_with_registry!(
617 "reputation_scores",
618 "Reputation scores for each authority",
619 &["authority"],
620 registry,
621 ).unwrap(),
622 scope_processing_time: register_histogram_vec_with_registry!(
623 "scope_processing_time",
624 "The processing time of a specific code scope",
625 &["scope"],
626 FINE_GRAINED_LATENCY_SEC_BUCKETS.to_vec(),
627 registry
628 ).unwrap(),
629 sub_dags_per_commit_count: register_histogram_with_registry!(
630 "sub_dags_per_commit_count",
631 "The number of subdags per commit.",
632 registry,
633 ).unwrap(),
634 block_suspensions: register_int_counter_vec_with_registry!(
635 "block_suspensions",
636 "The number block suspensions. The counter is reported uniquely, so if a block is sent for reprocessing while already suspended then is not double counted",
637 &["authority"],
638 registry,
639 ).unwrap(),
640 block_unsuspensions: register_int_counter_vec_with_registry!(
641 "block_unsuspensions",
642 "The number of block unsuspensions.",
643 &["authority"],
644 registry,
645 ).unwrap(),
646 suspended_block_time: register_histogram_vec_with_registry!(
647 "suspended_block_time",
648 "The time for which a block remains suspended",
649 &["authority"],
650 registry,
651 ).unwrap(),
652 block_manager_suspended_blocks: register_int_gauge_with_registry!(
653 "block_manager_suspended_blocks",
654 "The number of blocks currently suspended in the block manager",
655 registry,
656 ).unwrap(),
657 block_manager_missing_ancestors: register_int_gauge_with_registry!(
658 "block_manager_missing_ancestors",
659 "The number of missing ancestors tracked in the block manager",
660 registry,
661 ).unwrap(),
662 block_manager_missing_blocks: register_int_gauge_with_registry!(
663 "block_manager_missing_blocks",
664 "The number of blocks missing content tracked in the block manager",
665 registry,
666 ).unwrap(),
667 block_manager_missing_blocks_by_authority: register_int_counter_vec_with_registry!(
668 "block_manager_missing_blocks_by_authority",
669 "The number of new missing blocks by block authority",
670 &["authority"],
671 registry,
672 ).unwrap(),
673 block_manager_missing_ancestors_by_authority: register_int_counter_vec_with_registry!(
674 "block_manager_missing_ancestors_by_authority",
675 "The number of missing ancestors by ancestor authority across received blocks",
676 &["authority"],
677 registry,
678 ).unwrap(),
679 block_manager_gced_blocks: register_int_counter_vec_with_registry!(
680 "block_manager_gced_blocks",
681 "The number of blocks that garbage collected and did not get accepted, counted by block's source authority",
682 &["authority"],
683 registry,
684 ).unwrap(),
685 block_manager_gc_unsuspended_blocks: register_int_counter_vec_with_registry!(
686 "block_manager_gc_unsuspended_blocks",
687 "The number of blocks unsuspended because their missing ancestors are garbage collected by the block manager, counted by block's source authority",
688 &["authority"],
689 registry,
690 ).unwrap(),
691 block_manager_skipped_blocks: register_int_counter_vec_with_registry!(
692 "block_manager_skipped_blocks",
693 "The number of blocks skipped by the block manager due to block round being <= gc_round",
694 &["authority"],
695 registry,
696 ).unwrap(),
697 threshold_clock_round: register_int_gauge_with_registry!(
698 "threshold_clock_round",
699 "The current threshold clock round. We only advance to a new round when a quorum of parents have been synced.",
700 registry,
701 ).unwrap(),
702 subscriber_connection_attempts: register_int_counter_vec_with_registry!(
703 "subscriber_connection_attempts",
704 "The number of connection attempts per peer",
705 &["authority", "status"],
706 registry,
707 ).unwrap(),
708 subscribed_to: register_int_gauge_vec_with_registry!(
709 "subscribed_to",
710 "Peers that this authority subscribed to for block streams.",
711 &["authority"],
712 registry,
713 ).unwrap(),
714 subscribed_by: register_int_gauge_vec_with_registry!(
715 "subscribed_by",
716 "Peers subscribing for block streams from this authority.",
717 &["authority"],
718 registry,
719 ).unwrap(),
720 commit_sync_inflight_fetches: register_int_gauge_with_registry!(
721 "commit_sync_inflight_fetches",
722 "The number of inflight fetches in commit syncer",
723 registry,
724 ).unwrap(),
725 commit_sync_pending_fetches: register_int_gauge_with_registry!(
726 "commit_sync_pending_fetches",
727 "The number of pending fetches in commit syncer",
728 registry,
729 ).unwrap(),
730 commit_sync_fetched_commits: register_int_counter_with_registry!(
731 "commit_sync_fetched_commits",
732 "The number of commits fetched via commit syncer",
733 registry,
734 ).unwrap(),
735 commit_sync_fetched_blocks: register_int_counter_with_registry!(
736 "commit_sync_fetched_blocks",
737 "The number of blocks fetched via commit syncer",
738 registry,
739 ).unwrap(),
740 commit_sync_total_fetched_blocks_size: register_int_counter_with_registry!(
741 "commit_sync_total_fetched_blocks_size",
742 "The total size in bytes of blocks fetched via commit syncer",
743 registry,
744 ).unwrap(),
745 commit_sync_quorum_index: register_int_gauge_with_registry!(
746 "commit_sync_quorum_index",
747 "The maximum commit index voted by a quorum of authorities",
748 registry,
749 ).unwrap(),
750 commit_sync_highest_synced_index: register_int_gauge_with_registry!(
751 "commit_sync_fetched_index",
752 "The max commit index among local and fetched commits",
753 registry,
754 ).unwrap(),
755 commit_sync_highest_fetched_index: register_int_gauge_with_registry!(
756 "commit_sync_highest_fetched_index",
757 "The max commit index that has been fetched via network",
758 registry,
759 ).unwrap(),
760 commit_sync_local_index: register_int_gauge_with_registry!(
761 "commit_sync_local_index",
762 "The local commit index",
763 registry,
764 ).unwrap(),
765 commit_sync_gap_on_processing: register_int_counter_with_registry!(
766 "commit_sync_gap_on_processing",
767 "Number of instances where a gap was found in fetched commit processing",
768 registry,
769 ).unwrap(),
770 commit_sync_fetch_loop_latency: register_histogram_with_registry!(
771 "commit_sync_fetch_loop_latency",
772 "The time taken to finish fetching commits and blocks from a given range",
773 LATENCY_SEC_BUCKETS.to_vec(),
774 registry,
775 ).unwrap(),
776 commit_sync_fetch_once_latency: register_histogram_with_registry!(
777 "commit_sync_fetch_once_latency",
778 "The time taken to fetch commits and blocks once",
779 LATENCY_SEC_BUCKETS.to_vec(),
780 registry,
781 ).unwrap(),
782 commit_sync_fetch_once_errors: register_int_counter_vec_with_registry!(
783 "commit_sync_fetch_once_errors",
784 "Number of errors when attempting to fetch commits and blocks from single authority during commit sync.",
785 &["authority", "error"],
786 registry
787 ).unwrap(),
788 commit_sync_fetch_missing_blocks: register_int_counter_vec_with_registry!(
789 "commit_sync_fetch_missing_blocks",
790 "Number of ancestor blocks that are missing when processing blocks via commit sync.",
791 &["authority"],
792 registry,
793 ).unwrap(),
794 commit_sync_fetch_commits_handler_uncertified_skipped: register_int_counter_with_registry!(
795 "commit_sync_fetch_commits_handler_uncertified_skipped",
796 "Number of uncertified commits that got skipped when fetching commits due to lack of votes",
797 registry,
798 ).unwrap(),
799 round_tracker_received_quorum_round_gaps: register_int_gauge_vec_with_registry!(
800 "round_tracker_received_quorum_round_gaps",
801 "Received round gaps among peers for blocks proposed from each authority",
802 &["authority"],
803 registry
804 ).unwrap(),
805 round_tracker_accepted_quorum_round_gaps: register_int_gauge_vec_with_registry!(
806 "round_tracker_accepted_quorum_round_gaps",
807 "Accepted round gaps among peers for blocks proposed & accepted from each authority",
808 &["authority"],
809 registry
810 ).unwrap(),
811 round_tracker_low_received_quorum_round: register_int_gauge_vec_with_registry!(
812 "round_tracker_low_received_quorum_round",
813 "Low quorum round among peers for blocks proposed from each authority",
814 &["authority"],
815 registry
816 ).unwrap(),
817 round_tracker_low_accepted_quorum_round: register_int_gauge_vec_with_registry!(
818 "round_tracker_low_accepted_quorum_round",
819 "Low quorum round among peers for blocks proposed & accepted from each authority",
820 &["authority"],
821 registry
822 ).unwrap(),
823 round_tracker_current_received_round_gaps: register_int_gauge_vec_with_registry!(
824 "round_tracker_current_received_round_gaps",
825 "Received round gaps from local last proposed round to the low received quorum round of each peer. Can be negative.",
826 &["authority"],
827 registry
828 ).unwrap(),
829 round_tracker_current_accepted_round_gaps: register_int_gauge_vec_with_registry!(
830 "round_tracker_current_accepted_round_gaps",
831 "Accepted round gaps from local last proposed & accepted round to the low accepted quorum round of each peer. Can be negative.",
832 &["authority"],
833 registry
834 ).unwrap(),
835 round_tracker_propagation_delays: register_histogram_with_registry!(
836 "round_tracker_propagation_delays",
837 "Round gaps between the last proposed block round and the lower bound of own quorum round",
838 NUM_BUCKETS.to_vec(),
839 registry
840 ).unwrap(),
841 round_tracker_last_propagation_delay: register_int_gauge_with_registry!(
842 "round_tracker_last_propagation_delay",
843 "Most recent propagation delay observed by RoundTracker",
844 registry
845 ).unwrap(),
846 round_prober_request_errors: register_int_counter_vec_with_registry!(
847 "round_prober_request_errors",
848 "Number of errors when probing against peers per error type",
849 &["error_type"],
850 registry
851 ).unwrap(),
852 certifier_gc_round: register_int_gauge_with_registry!(
853 "certifier_gc_round",
854 "The current GC round of the certifier",
855 registry
856 ).unwrap(),
857 certifier_own_reject_votes: register_int_counter_vec_with_registry!(
858 "certifier_own_reject_votes",
859 "Number of own reject votes against each peer authority",
860 &["authority"],
861 registry
862 ).unwrap(),
863 finalizer_buffered_commits: register_int_gauge_with_registry!(
864 "finalizer_buffered_commits",
865 "The number of commits buffered in the finalizer",
866 registry,
867 ).unwrap(),
868 finalizer_round_delay: register_histogram_with_registry!(
869 "finalizer_round_delay",
870 "The delay between the round of the last committed block and the round of the finalized commit.",
871 ROUND_DELAY_BUCKETS.to_vec(),
872 registry,
873 ).unwrap(),
874 finalizer_transaction_status: register_int_counter_vec_with_registry!(
875 "finalizer_transaction_status",
876 "Number of transactions finalized by the finalizer, grouped by status.",
877 &["status"],
878 registry
879 ).unwrap(),
880 finalizer_reject_votes: register_int_counter_vec_with_registry!(
881 "finalizer_reject_votes",
882 "Number of reject votes casted by each authority observed by the finalizer.",
883 &["authority"],
884 registry
885 ).unwrap(),
886 finalizer_output_commits: register_int_counter_vec_with_registry!(
887 "finalizer_output_commits",
888 "Number of output commits finalized by the finalizer, grouped by type.",
889 &["type"],
890 registry
891 ).unwrap(),
892 finalizer_skipped_voting_blocks: register_int_counter_vec_with_registry!(
893 "finalizer_skipped_voting_blocks",
894 "Number of times where another block skipped voting due to potentially out of GC bound. Authority is from the voted block.",
895 &["authority", "type"],
896 registry
897 ).unwrap(),
898 uptime: register_histogram_with_registry!(
899 "uptime",
900 "Total node uptime",
901 LATENCY_SEC_BUCKETS.to_vec(),
902 registry,
903 ).unwrap(),
904 }
905 }
906}