sui_core/validator_client_monitor/
metrics.rs1use mysten_metrics::{COUNT_BUCKETS, SUBSECOND_LATENCY_SEC_BUCKETS};
5use prometheus::{
6 GaugeVec, Histogram, HistogramVec, IntCounterVec, IntGauge, Registry,
7 register_gauge_vec_with_registry, register_histogram_vec_with_registry,
8 register_histogram_with_registry, register_int_counter_vec_with_registry,
9 register_int_gauge_with_registry,
10};
11
12#[derive(Clone)]
13pub struct ValidatorClientMetrics {
14 pub observed_latency: HistogramVec,
16
17 pub operation_success: IntCounterVec,
19
20 pub operation_failure: IntCounterVec,
22
23 pub performance: GaugeVec,
26
27 pub shuffled_validators: Histogram,
29
30 pub staggering_active: IntGauge,
32
33 pub staggering_active_stake: IntGauge,
35}
36
37impl ValidatorClientMetrics {
38 pub fn new(registry: &Registry) -> Self {
39 Self {
40 observed_latency: register_histogram_vec_with_registry!(
41 "validator_client_observed_latency",
42 "Client-observed latency of operations per validator",
43 &["validator", "operation_type", "ping"],
44 SUBSECOND_LATENCY_SEC_BUCKETS.to_vec(),
45 registry,
46 )
47 .unwrap(),
48
49 operation_success: register_int_counter_vec_with_registry!(
50 "validator_client_operation_success_total",
51 "Total successful operations observed by client per validator",
52 &["validator", "operation_type", "ping"],
53 registry,
54 )
55 .unwrap(),
56
57 operation_failure: register_int_counter_vec_with_registry!(
58 "validator_client_operation_failure_total",
59 "Total failed operations observed by client per validator",
60 &["validator", "operation_type", "ping"],
61 registry,
62 )
63 .unwrap(),
64
65 performance: register_gauge_vec_with_registry!(
66 "validator_client_observed_performance",
67 "Current client-observed performance per validator and transaction class. The performance is the average latency of the validator
68 weighted by the reliability of the validator.",
69 &["validator", "tx_class"],
70 registry,
71 )
72 .unwrap(),
73
74 shuffled_validators: register_histogram_with_registry!(
75 "validator_client_shuffled_validators",
76 "Number of low latency validators that got shuffled",
77 COUNT_BUCKETS.to_vec(),
78 registry,
79 )
80 .unwrap(),
81
82 staggering_active: register_int_gauge_with_registry!(
83 "validator_client_staggering_active",
84 "Whether the driver considers staggered submission active (1) or not (0); while active, transactions without allowed proposers are targeted at their free stagger slots",
85 registry,
86 )
87 .unwrap(),
88
89 staggering_active_stake: register_int_gauge_with_registry!(
90 "validator_client_staggering_active_stake",
91 "Stake of validators with a fresh report of staggering being active; staggering is considered active once this reaches the committee's validity threshold (f+1)",
92 registry,
93 )
94 .unwrap(),
95 }
96 }
97
98 pub fn new_for_tests() -> Self {
99 let registry = Registry::new();
100 Self::new(®istry)
101 }
102}