From 873607502cbbe5abeed111154d722a1682df701a Mon Sep 17 00:00:00 2001 From: int88 <106391185+int88@users.noreply.github.com> Date: Thu, 20 Jul 2023 01:27:08 +0800 Subject: [PATCH] feat: add reorg metrics (#3824) --- crates/blockchain-tree/src/blockchain_tree.rs | 1 + crates/blockchain-tree/src/metrics.rs | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/crates/blockchain-tree/src/blockchain_tree.rs b/crates/blockchain-tree/src/blockchain_tree.rs index 819d60d4c3..6c5f2fe3d6 100644 --- a/crates/blockchain-tree/src/blockchain_tree.rs +++ b/crates/blockchain-tree/src/blockchain_tree.rs @@ -1003,6 +1003,7 @@ impl BlockchainTree }; // insert old canon chain self.insert_chain(AppendableChain::new(old_canon_chain)); + self.metrics.reorgs.increment(1); } else { // error here to confirm that we are reverting nothing from db. error!(target: "blockchain_tree", "Reverting nothing from db on block: #{:?}", block_hash); diff --git a/crates/blockchain-tree/src/metrics.rs b/crates/blockchain-tree/src/metrics.rs index 38610c5a69..864fac9474 100644 --- a/crates/blockchain-tree/src/metrics.rs +++ b/crates/blockchain-tree/src/metrics.rs @@ -1,5 +1,5 @@ use reth_metrics::{ - metrics::{self, Gauge}, + metrics::{self, Counter, Gauge}, Metrics, }; @@ -11,6 +11,8 @@ pub struct TreeMetrics { pub sidechains: Gauge, /// The highest block number in the canonical chain pub canonical_chain_height: Gauge, + /// The number of reorgs + pub reorgs: Counter, } /// Metrics for the blockchain tree block buffer