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