mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-02-26 15:47:21 +00:00
metrics: add chain/gas for cumulative gas usage (#32004)
This is a followup to #31753. A cumulative counter is more useful when we need to measure / aggregate the metric over a longer period 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 pre-aggregated mgas/s. --------- Co-authored-by: Gary Rong <garyrong0905@gmail.com>
This commit is contained in:
parent
5605f9d7ad
commit
82c2c8191f
2 changed files with 7 additions and 5 deletions
|
|
@ -66,7 +66,7 @@ var (
|
|||
headSafeBlockGauge = metrics.NewRegisteredGauge("chain/head/safe", nil)
|
||||
|
||||
chainInfoGauge = metrics.NewRegisteredGaugeInfo("chain/info", nil)
|
||||
chainMgaspsGauge = metrics.NewRegisteredGauge("chain/mgasps", nil)
|
||||
chainMgaspsMeter = metrics.NewRegisteredResettingTimer("chain/mgasps", nil)
|
||||
|
||||
accountReadTimer = metrics.NewRegisteredResettingTimer("chain/account/reads", nil)
|
||||
accountHashTimer = metrics.NewRegisteredResettingTimer("chain/account/hashes", nil)
|
||||
|
|
@ -2067,7 +2067,12 @@ func (bc *BlockChain) processBlock(parentRoot common.Hash, block *types.Block, s
|
|||
triedbCommitTimer.Update(statedb.TrieDBCommits) // Trie database commits are complete, we can mark them
|
||||
|
||||
blockWriteTimer.Update(time.Since(wstart) - max(statedb.AccountCommits, statedb.StorageCommits) /* concurrent */ - statedb.SnapshotCommits - statedb.TrieDBCommits)
|
||||
blockInsertTimer.UpdateSince(startTime)
|
||||
elapsed := time.Since(startTime) + 1 // prevent zero division
|
||||
blockInsertTimer.Update(elapsed)
|
||||
|
||||
// TODO(rjl493456442) generalize the ResettingTimer
|
||||
mgasps := float64(res.GasUsed) * 1000 / float64(elapsed)
|
||||
chainMgaspsMeter.Update(time.Duration(mgasps))
|
||||
|
||||
return &blockProcessingResult{
|
||||
usedGas: res.GasUsed,
|
||||
|
|
|
|||
|
|
@ -46,9 +46,6 @@ func (st *insertStats) report(chain []*types.Block, index int, snapDiffItems, sn
|
|||
elapsed = now.Sub(st.startTime) + 1 // prevent zero division
|
||||
mgasps = float64(st.usedGas) * 1000 / float64(elapsed)
|
||||
)
|
||||
// Update the Mgas per second gauge
|
||||
chainMgaspsGauge.Update(int64(mgasps))
|
||||
|
||||
// If we're at the last block of the batch or report period reached, log
|
||||
if index == len(chain)-1 || elapsed >= statsReportLimit {
|
||||
// Count the number of transactions in this segment
|
||||
|
|
|
|||
Loading…
Reference in a new issue