metrics: add chain/gas for cumulative gas usage

This commit is contained in:
Sean Liao 2025-07-29 10:14:53 +00:00
parent a56558d092
commit 1196feec4d
No known key found for this signature in database

View file

@ -67,6 +67,7 @@ var (
chainInfoGauge = metrics.NewRegisteredGaugeInfo("chain/info", nil) chainInfoGauge = metrics.NewRegisteredGaugeInfo("chain/info", nil)
chainMgaspsMeter = metrics.NewRegisteredResettingTimer("chain/mgasps", nil) chainMgaspsMeter = metrics.NewRegisteredResettingTimer("chain/mgasps", nil)
chainGasCounter = metrics.NewRegisteredCounter("chain/gas/total", nil)
accountReadTimer = metrics.NewRegisteredResettingTimer("chain/account/reads", nil) accountReadTimer = metrics.NewRegisteredResettingTimer("chain/account/reads", nil)
accountHashTimer = metrics.NewRegisteredResettingTimer("chain/account/hashes", nil) accountHashTimer = metrics.NewRegisteredResettingTimer("chain/account/hashes", nil)
@ -1888,6 +1889,7 @@ func (bc *BlockChain) insertChain(chain types.Blocks, setHead bool, makeWitness
// Report the import stats before returning the various results // Report the import stats before returning the various results
stats.processed++ stats.processed++
stats.usedGas += res.usedGas stats.usedGas += res.usedGas
chainGasCounter.Inc(int64(res.usedGas))
witness = res.witness witness = res.witness
var snapDiffItems, snapBufItems common.StorageSize var snapDiffItems, snapBufItems common.StorageSize