From 96b7572bb5152a1640d53df21fdd1f46f085b58d Mon Sep 17 00:00:00 2001 From: teor Date: Fri, 6 Nov 2020 16:25:03 +1000 Subject: [PATCH] Make the checkpoint metrics more accurate --- zebra-consensus/src/checkpoint.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/zebra-consensus/src/checkpoint.rs b/zebra-consensus/src/checkpoint.rs index d4018c434..4e1b8e822 100644 --- a/zebra-consensus/src/checkpoint.rs +++ b/zebra-consensus/src/checkpoint.rs @@ -400,6 +400,14 @@ where /// Increase the current checkpoint height to `verified_height`, fn update_progress(&mut self, verified_height: block::Height) { + if let Some(max_height) = self.queued.keys().next_back() { + metrics::gauge!("checkpoint.queued.max.height", max_height.0 as i64); + } else { + // use -1 as a sentinel value for "None", because 0 is a valid height + metrics::gauge!("checkpoint.queued.max.height", -1); + } + metrics::gauge!("checkpoint.queued_slots", self.queued.len() as i64); + // Ignore blocks that are below the previous checkpoint, or otherwise // have invalid heights. // @@ -837,8 +845,6 @@ where // should be rare. self.process_checkpoint_range(); - metrics::gauge!("checkpoint.queued_slots", self.queued.len() as i64); - let mut state_service = self.state_service.clone(); async move { let hash = rx