Skip to content

Commit

Permalink
Use histogram for reprocessing queue
Browse files Browse the repository at this point in the history
  • Loading branch information
paulhauner committed Jul 18, 2023
1 parent 93baac2 commit 8fb6bc3
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 18 deletions.
18 changes: 12 additions & 6 deletions beacon_node/beacon_processor/src/metrics.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
pub use lighthouse_metrics::*;

fn queue_length_buckets() -> Vec<f64> {
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! {

/*
Expand Down Expand Up @@ -43,18 +49,18 @@ lazy_static::lazy_static! {
);
pub static ref BEACON_PROCESSOR_QUEUE_LENGTHS: Result<HistogramVec> = 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<IntGaugeVec> =
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<HistogramVec> = 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<IntCounter> = try_create_int_counter(
Expand Down
24 changes: 12 additions & 12 deletions beacon_node/beacon_processor/src/work_reprocessing_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -887,25 +887,25 @@ impl<S: SlotClock> ReprocessQueue<S> {
}
}

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,
);
}

Expand Down

0 comments on commit 8fb6bc3

Please sign in to comment.