Skip to content

Commit 763f288

Browse files
committed
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.
1 parent 23f07d8 commit 763f288

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

core/blockchain.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ var (
6767

6868
chainInfoGauge = metrics.NewRegisteredGaugeInfo("chain/info", nil)
6969
chainMgaspsGauge = metrics.NewRegisteredGauge("chain/mgasps", nil)
70+
chainGasCounter = metrics.NewRegisteredCounter("chain/gas", nil)
7071

7172
accountReadTimer = metrics.NewRegisteredResettingTimer("chain/account/reads", nil)
7273
accountHashTimer = metrics.NewRegisteredResettingTimer("chain/account/hashes", nil)
@@ -1844,6 +1845,7 @@ func (bc *BlockChain) insertChain(chain types.Blocks, setHead bool, makeWitness
18441845
// Report the import stats before returning the various results
18451846
stats.processed++
18461847
stats.usedGas += res.usedGas
1848+
chainGasCounter.Inc(int64(res.usedGas))
18471849
witness = res.witness
18481850

18491851
var snapDiffItems, snapBufItems common.StorageSize

0 commit comments

Comments
 (0)