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.
This commit is contained in:
Sean Liao 2025-06-04 10:57:56 +00:00
parent 23f07d8c93
commit f1eee7f7f5
No known key found for this signature in database

View file

@ -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