mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-22 22:34:45 +00:00
Add metrics for beacon block propagation (#2173)
## Issue Addressed NA ## Proposed Changes Adds some metrics to track delays regarding: - LH processing of blocks - delays receiving blocks from other nodes. ## Additional Info NA
This commit is contained in:
@@ -252,14 +252,8 @@ pub fn start_timer(histogram: &Result<Histogram>) -> Option<HistogramTimer> {
|
||||
|
||||
/// Starts a timer on `vec` with the given `name`.
|
||||
pub fn observe_timer_vec(vec: &Result<HistogramVec>, name: &[&str], duration: Duration) {
|
||||
// This conversion was taken from here:
|
||||
//
|
||||
// https://docs.rs/prometheus/0.5.0/src/prometheus/histogram.rs.html#550-555
|
||||
let nanos = f64::from(duration.subsec_nanos()) / 1e9;
|
||||
let secs = duration.as_secs() as f64 + nanos;
|
||||
|
||||
if let Some(h) = get_histogram(vec, name) {
|
||||
h.observe(secs)
|
||||
h.observe(duration_to_f64(duration))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -330,3 +324,17 @@ pub fn observe(histogram: &Result<Histogram>, value: f64) {
|
||||
histogram.observe(value);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn observe_duration(histogram: &Result<Histogram>, duration: Duration) {
|
||||
if let Ok(histogram) = histogram {
|
||||
histogram.observe(duration_to_f64(duration))
|
||||
}
|
||||
}
|
||||
|
||||
fn duration_to_f64(duration: Duration) -> f64 {
|
||||
// This conversion was taken from here:
|
||||
//
|
||||
// https://docs.rs/prometheus/0.5.0/src/prometheus/histogram.rs.html#550-555
|
||||
let nanos = f64::from(duration.subsec_nanos()) / 1e9;
|
||||
duration.as_secs() as f64 + nanos
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user