Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sync-speed metric #898

Merged
merged 1 commit into from
Mar 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions beacon_node/client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,5 @@ genesis = { path = "../genesis" }
environment = { path = "../../lighthouse/environment" }
lighthouse_bootstrap = { path = "../../eth2/utils/lighthouse_bootstrap" }
eth2_ssz = { path = "../../eth2/utils/ssz" }
lazy_static = "1.4.0"
lighthouse_metrics = { path = "../../eth2/utils/lighthouse_metrics" }
1 change: 1 addition & 0 deletions beacon_node/client/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
extern crate slog;

pub mod config;
mod metrics;
mod notifier;

pub mod builder;
Expand Down
9 changes: 9 additions & 0 deletions beacon_node/client/src/metrics.rs
Original file line number Diff line number Diff line change
@@ -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"
);
}
3 changes: 3 additions & 0 deletions beacon_node/client/src/notifier.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use crate::metrics;
use beacon_chain::{BeaconChain, BeaconChainTypes};
use environment::RuntimeContext;
use exit_future::Signal;
Expand Down Expand Up @@ -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;

Expand Down