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