sui_core/validator_client_monitor/
metrics.rsuse mysten_metrics::{COUNT_BUCKETS, LATENCY_SEC_BUCKETS};
use prometheus::{
register_gauge_vec_with_registry, register_histogram_vec_with_registry,
register_int_counter_vec_with_registry, GaugeVec, HistogramVec, IntCounterVec, Registry,
};
#[derive(Clone)]
pub struct ValidatorClientMetrics {
pub observed_latency: HistogramVec,
pub operation_success: IntCounterVec,
pub operation_failure: IntCounterVec,
pub performance: GaugeVec,
pub shuffled_validators: HistogramVec,
}
impl ValidatorClientMetrics {
pub fn new(registry: &Registry) -> Self {
Self {
observed_latency: register_histogram_vec_with_registry!(
"validator_client_observed_latency",
"Client-observed latency of operations per validator",
&["validator", "operation_type", "ping"],
LATENCY_SEC_BUCKETS.to_vec(),
registry,
)
.unwrap(),
operation_success: register_int_counter_vec_with_registry!(
"validator_client_operation_success_total",
"Total successful operations observed by client per validator",
&["validator", "operation_type", "ping"],
registry,
)
.unwrap(),
operation_failure: register_int_counter_vec_with_registry!(
"validator_client_operation_failure_total",
"Total failed operations observed by client per validator",
&["validator", "operation_type", "ping"],
registry,
)
.unwrap(),
performance: register_gauge_vec_with_registry!(
"validator_client_observed_performance",
"Current client-observed performance per validator. The performance is the average latency of the validator
weighted by the reliability of the validator.",
&["validator", "tx_type"],
registry,
)
.unwrap(),
shuffled_validators: register_histogram_vec_with_registry!(
"validator_client_shuffled_validators",
"Number of low latency validators that got shuffled",
&["tx_type"],
COUNT_BUCKETS.to_vec(),
registry,
)
.unwrap(),
}
}
pub fn new_for_tests() -> Self {
let registry = Registry::new();
Self::new(®istry)
}
}