Add sync-speed metric (#898)

This commit is contained in:
Paul Hauner
2020-03-18 09:25:29 +11:00
committed by GitHub
parent c198bddf9e
commit 3c8fe00510
5 changed files with 17 additions and 0 deletions

View File

@@ -1,6 +1,7 @@
extern crate slog;
pub mod config;
mod metrics;
mod notifier;
pub mod builder;

View File

@@ -0,0 +1,9 @@
use lazy_static::lazy_static;
pub use lighthouse_metrics::*;
lazy_static! {
pub static ref SYNC_SLOTS_PER_SECOND: Result<IntGauge> = try_create_int_gauge(
"sync_slots_per_second",
"The number of blocks being imported per second"
);
}

View File

@@ -1,3 +1,4 @@
use crate::metrics;
use beacon_chain::{BeaconChain, BeaconChainTypes};
use environment::RuntimeContext;
use exit_future::Signal;
@@ -83,6 +84,8 @@ pub fn spawn_notifier<T: BeaconChainTypes>(
let mut speedo = speedo.lock();
speedo.observe(head_slot, Instant::now());
metrics::set_gauge(&metrics::SYNC_SLOTS_PER_SECOND, speedo.slots_per_second().unwrap_or_else(|| 0_f64) as i64);
// The next two lines take advantage of saturating subtraction on `Slot`.
let head_distance = current_slot - head_slot;