Add more eth1 metrics (#728)

* Add metrics for junk eth1 votes

* Add eth1 cache metrics
This commit is contained in:
Paul Hauner 2019-12-17 10:20:27 +11:00 committed by GitHub
parent 61be1491a1
commit 34f003adb8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 61 additions and 0 deletions

2
Cargo.lock generated
View File

@ -1047,7 +1047,9 @@ dependencies = [
"exit-future 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "exit-future 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)",
"hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libflate 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "libflate 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)",
"lighthouse_metrics 0.1.0",
"merkle_proof 0.1.0", "merkle_proof 0.1.0",
"parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
"reqwest 0.9.22 (registry+https://github.com/rust-lang/crates.io-index)", "reqwest 0.9.22 (registry+https://github.com/rust-lang/crates.io-index)",

View File

@ -1,3 +1,4 @@
use crate::metrics;
use eth1::{Config as Eth1Config, Eth1Block, Service as HttpService}; use eth1::{Config as Eth1Config, Eth1Block, Service as HttpService};
use eth2_hashing::hash; use eth2_hashing::hash;
use exit_future::Exit; use exit_future::Exit;
@ -351,6 +352,8 @@ impl<T: EthSpec, S: Store<T>> Eth1ChainBackend<T> for CachingEth1Backend<T, S> {
fn random_eth1_data() -> Eth1Data { fn random_eth1_data() -> Eth1Data {
let mut rng = rand::thread_rng(); let mut rng = rand::thread_rng();
metrics::inc_counter(&metrics::JUNK_ETH1_VOTES);
macro_rules! rand_bytes { macro_rules! rand_bytes {
($num_bytes: expr) => {{ ($num_bytes: expr) => {{
let mut arr = [0_u8; $num_bytes]; let mut arr = [0_u8; $num_bytes];

View File

@ -153,6 +153,12 @@ lazy_static! {
pub static ref CHECKPOINT_CACHE_MISSES: Result<IntCounter> = pub static ref CHECKPOINT_CACHE_MISSES: Result<IntCounter> =
try_create_int_counter("beacon_checkpoint_cache_misses_total", "Count of times checkpoint cache fulfils request"); try_create_int_counter("beacon_checkpoint_cache_misses_total", "Count of times checkpoint cache fulfils request");
/*
* Eth1
*/
pub static ref JUNK_ETH1_VOTES: Result<IntCounter> =
try_create_int_counter("beacon_eth1_junk_votes", "Count of times we have voted junk for eth1 dat");
/* /*
* Chain Head * Chain Head
*/ */

View File

@ -27,3 +27,5 @@ tokio = "0.1.22"
state_processing = { path = "../../eth2/state_processing" } state_processing = { path = "../../eth2/state_processing" }
exit-future = "0.1.4" exit-future = "0.1.4"
libflate = "0.1" libflate = "0.1"
lighthouse_metrics = { path = "../../eth2/utils/lighthouse_metrics"}
lazy_static = "1.4.0"

View File

@ -1,8 +1,12 @@
#[macro_use]
extern crate lazy_static;
mod block_cache; mod block_cache;
mod deposit_cache; mod deposit_cache;
mod deposit_log; mod deposit_log;
pub mod http; pub mod http;
mod inner; mod inner;
mod metrics;
mod service; mod service;
pub use block_cache::{BlockCache, Eth1Block}; pub use block_cache::{BlockCache, Eth1Block};

View File

@ -0,0 +1,19 @@
pub use lighthouse_metrics::*;
lazy_static! {
/*
* Eth1 blocks
*/
pub static ref BLOCK_CACHE_LEN: Result<IntGauge> =
try_create_int_gauge("eth1_block_cache_len", "Count of eth1 blocks in cache");
pub static ref LATEST_CACHED_BLOCK_TIMESTAMP: Result<IntGauge> =
try_create_int_gauge("eth1_latest_cached_block_timestamp", "Timestamp of latest block in eth1 cache");
/*
* Eth1 deposits
*/
pub static ref DEPOSIT_CACHE_LEN: Result<IntGauge> =
try_create_int_gauge("eth1_deposit_cache_len", "Number of deposits in the eth1 cache");
pub static ref HIGHEST_PROCESSED_DEPOSIT_BLOCK: Result<IntGauge> =
try_create_int_gauge("eth1_highest_processed_deposit_block", "Number of the last block checked for deposits");
}

View File

@ -1,3 +1,4 @@
use crate::metrics;
use crate::{ use crate::{
block_cache::{BlockCache, Error as BlockCacheError, Eth1Block}, block_cache::{BlockCache, Error as BlockCacheError, Eth1Block},
deposit_cache::Error as DepositCacheError, deposit_cache::Error as DepositCacheError,
@ -461,6 +462,12 @@ impl Service {
cache.last_processed_block = Some(block_range.end.saturating_sub(1)); cache.last_processed_block = Some(block_range.end.saturating_sub(1));
metrics::set_gauge(&metrics::DEPOSIT_CACHE_LEN, cache.cache.len() as i64);
metrics::set_gauge(
&metrics::HIGHEST_PROCESSED_DEPOSIT_BLOCK,
cache.last_processed_block.unwrap_or_else(|| 0) as i64,
);
Ok(sum) Ok(sum)
}) })
.map(|logs_imported| DepositCacheUpdateOutcome::Success { logs_imported }) .map(|logs_imported| DepositCacheUpdateOutcome::Success { logs_imported })
@ -559,6 +566,19 @@ impl Service {
.insert_root_or_child(eth1_block) .insert_root_or_child(eth1_block)
.map_err(Error::FailedToInsertEth1Block)?; .map_err(Error::FailedToInsertEth1Block)?;
metrics::set_gauge(
&metrics::BLOCK_CACHE_LEN,
cache_3.block_cache.read().len() as i64,
);
metrics::set_gauge(
&metrics::LATEST_CACHED_BLOCK_TIMESTAMP,
cache_3
.block_cache
.read()
.latest_block_timestamp()
.unwrap_or_else(|| 0) as i64,
);
Ok(sum + 1) Ok(sum + 1)
}) })
}) })
@ -566,6 +586,11 @@ impl Service {
// Prune the block cache, preventing it from growing too large. // Prune the block cache, preventing it from growing too large.
cache_4.prune_blocks(); cache_4.prune_blocks();
metrics::set_gauge(
&metrics::BLOCK_CACHE_LEN,
cache_4.block_cache.read().len() as i64,
);
Ok(BlockCacheUpdateOutcome::Success { Ok(BlockCacheUpdateOutcome::Success {
blocks_imported, blocks_imported,
head_block_number: cache_4.clone().block_cache.read().highest_block_number(), head_block_number: cache_4.clone().block_cache.read().highest_block_number(),