From 7d3948c8fe32a7624d7fafaf2561a1f8ac291e3f Mon Sep 17 00:00:00 2001 From: Paul Hauner Date: Tue, 13 Sep 2022 17:19:27 +0000 Subject: [PATCH] Add metric for re-org distance (#3566) ## Issue Addressed NA ## Proposed Changes Add a metric to track the re-org distance. ## Additional Info NA --- beacon_node/beacon_chain/src/canonical_head.rs | 4 ++++ beacon_node/beacon_chain/src/metrics.rs | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/beacon_node/beacon_chain/src/canonical_head.rs b/beacon_node/beacon_chain/src/canonical_head.rs index 644364bc6..c9bd6db0e 100644 --- a/beacon_node/beacon_chain/src/canonical_head.rs +++ b/beacon_node/beacon_chain/src/canonical_head.rs @@ -1189,6 +1189,10 @@ fn detect_reorg( metrics::inc_counter(&metrics::FORK_CHOICE_REORG_COUNT); metrics::inc_counter(&metrics::FORK_CHOICE_REORG_COUNT_INTEROP); + metrics::set_gauge( + &metrics::FORK_CHOICE_REORG_DISTANCE, + reorg_distance.as_u64() as i64, + ); warn!( log, "Beacon chain re-org"; diff --git a/beacon_node/beacon_chain/src/metrics.rs b/beacon_node/beacon_chain/src/metrics.rs index cad77a378..b454a6ff8 100644 --- a/beacon_node/beacon_chain/src/metrics.rs +++ b/beacon_node/beacon_chain/src/metrics.rs @@ -305,6 +305,10 @@ lazy_static! { "beacon_fork_choice_reorg_total", "Count of occasions fork choice has switched to a different chain" ); + pub static ref FORK_CHOICE_REORG_DISTANCE: Result = try_create_int_gauge( + "beacon_fork_choice_reorg_distance", + "The distance of each re-org of the fork choice algorithm" + ); pub static ref FORK_CHOICE_REORG_COUNT_INTEROP: Result = try_create_int_counter( "beacon_reorgs_total", "Count of occasions fork choice has switched to a different chain"