From 8fb6bc39c29dab278efa0fcf2fbcbb39ebd2a1d4 Mon Sep 17 00:00:00 2001 From: Paul Hauner Date: Tue, 18 Jul 2023 17:56:38 +1000 Subject: [PATCH] Use histogram for reprocessing queue --- beacon_node/beacon_processor/src/metrics.rs | 18 +++++++++----- .../src/work_reprocessing_queue.rs | 24 +++++++++---------- 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/beacon_node/beacon_processor/src/metrics.rs b/beacon_node/beacon_processor/src/metrics.rs index edff43606a4..f02233d8a9a 100644 --- a/beacon_node/beacon_processor/src/metrics.rs +++ b/beacon_node/beacon_processor/src/metrics.rs @@ -1,5 +1,11 @@ pub use lighthouse_metrics::*; +fn queue_length_buckets() -> Vec { + vec![ + 0.0, 1.0, 4.0, 16.0, 64.0, 256.0, 1024.0, 4096.0, 16384.0, 65536.0, + ] +} + lazy_static::lazy_static! { /* @@ -43,18 +49,18 @@ lazy_static::lazy_static! { ); pub static ref BEACON_PROCESSOR_QUEUE_LENGTHS: Result = try_create_histogram_vec_with_buckets( "beacon_processor_queue_lengths", - "The lengths of beacon processor event queues.", - Ok(vec![0.0, 1.0, 4.0, 16.0, 64.0, 256.0, 1024.0, 4096.0, 16384.0, 32768.0]), + "The lengths of each beacon processor event queue.", + Ok(queue_length_buckets()), &["type"] ); /* * Attestation reprocessing queue metrics. */ - pub static ref BEACON_PROCESSOR_REPROCESSING_QUEUE_TOTAL: Result = - try_create_int_gauge_vec( - "beacon_processor_reprocessing_queue_total", - "Count of items in a reprocessing queue.", + pub static ref BEACON_PROCESSOR_REPROCESSING_QUEUE_LENGTHS: Result = try_create_histogram_vec_with_buckets( + "beacon_processor_reprocessing_queue_lengths", + "The lengths of each beacon processor reprocessing queue.", + Ok(queue_length_buckets()), &["type"] ); pub static ref BEACON_PROCESSOR_REPROCESSING_QUEUE_EXPIRED_ATTESTATIONS: Result = try_create_int_counter( diff --git a/beacon_node/beacon_processor/src/work_reprocessing_queue.rs b/beacon_node/beacon_processor/src/work_reprocessing_queue.rs index 608f634d537..fdd21439083 100644 --- a/beacon_node/beacon_processor/src/work_reprocessing_queue.rs +++ b/beacon_node/beacon_processor/src/work_reprocessing_queue.rs @@ -887,25 +887,25 @@ impl ReprocessQueue { } } - metrics::set_gauge_vec( - &metrics::BEACON_PROCESSOR_REPROCESSING_QUEUE_TOTAL, + metrics::observe_histogram_vec( + &metrics::BEACON_PROCESSOR_REPROCESSING_QUEUE_LENGTHS, &[GOSSIP_BLOCKS], - self.gossip_block_delay_queue.len() as i64, + self.gossip_block_delay_queue.len() as f64, ); - metrics::set_gauge_vec( - &metrics::BEACON_PROCESSOR_REPROCESSING_QUEUE_TOTAL, + metrics::observe_histogram_vec( + &metrics::BEACON_PROCESSOR_REPROCESSING_QUEUE_LENGTHS, &[RPC_BLOCKS], - self.rpc_block_delay_queue.len() as i64, + self.rpc_block_delay_queue.len() as f64, ); - metrics::set_gauge_vec( - &metrics::BEACON_PROCESSOR_REPROCESSING_QUEUE_TOTAL, + metrics::observe_histogram_vec( + &metrics::BEACON_PROCESSOR_REPROCESSING_QUEUE_LENGTHS, &[ATTESTATIONS], - self.attestations_delay_queue.len() as i64, + self.attestations_delay_queue.len() as f64, ); - metrics::set_gauge_vec( - &metrics::BEACON_PROCESSOR_REPROCESSING_QUEUE_TOTAL, + metrics::observe_histogram_vec( + &metrics::BEACON_PROCESSOR_REPROCESSING_QUEUE_LENGTHS, &[LIGHT_CLIENT_UPDATES], - self.lc_updates_delay_queue.len() as i64, + self.lc_updates_delay_queue.len() as f64, ); }