From f1eee7f7f5f3615c4f460ab5e39775bb722789a3 Mon Sep 17 00:00:00 2001 From: Sean Liao Date: Wed, 4 Jun 2025 10:57:56 +0000 Subject: [PATCH] metrics: add chain/gas for cumulative gas usage This is a followup to #31753. A cumulative counter is more useful when we need to measure / aggregate the metric over a longer peruid of time. It also means we won't miss data, e.g. our prometheus scrapes every 30 seconds, and so may miss a transient spike in the preaggregated mgas/s. --- core/blockchain.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/blockchain.go b/core/blockchain.go index 64345bc1a3..0a61ebc218 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -67,6 +67,7 @@ var ( chainInfoGauge = metrics.NewRegisteredGaugeInfo("chain/info", nil) chainMgaspsGauge = metrics.NewRegisteredGauge("chain/mgasps", nil) + chainGasCounter = metrics.NewRegisteredCounter("chain/gas/total", nil) accountReadTimer = metrics.NewRegisteredResettingTimer("chain/account/reads", nil) accountHashTimer = metrics.NewRegisteredResettingTimer("chain/account/hashes", nil) @@ -1844,6 +1845,7 @@ func (bc *BlockChain) insertChain(chain types.Blocks, setHead bool, makeWitness // Report the import stats before returning the various results stats.processed++ stats.usedGas += res.usedGas + chainGasCounter.Inc(int64(res.usedGas)) witness = res.witness var snapDiffItems, snapBufItems common.StorageSize