Skip to content
This repository was archived by the owner on Jun 6, 2025. It is now read-only.

Commit 8076d0a

Browse files
authored
chore: add block's gas used and number of transactions metrics (#279)
1 parent e638c0a commit 8076d0a

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

core/blockchain.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ var (
8080
blockPrefetchExecuteTimer = metrics.NewRegisteredTimer("chain/prefetch/executes", nil)
8181
blockPrefetchInterruptMeter = metrics.NewRegisteredMeter("chain/prefetch/interrupts", nil)
8282

83+
blockTxsGauge = metrics.NewRegisteredGauge("chain/block/txs", nil)
84+
blockGasUsedGauge = metrics.NewRegisteredGauge("chain/block/gasUsed", nil)
85+
8386
errInsertionInterrupted = errors.New("insertion is interrupted")
8487
errChainStopped = errors.New("blockchain is stopped")
8588
)
@@ -1757,6 +1760,8 @@ func (bc *BlockChain) insertChain(chain types.Blocks, verifySeals bool) (int, er
17571760

17581761
blockWriteTimer.Update(time.Since(substart) - statedb.AccountCommits - statedb.StorageCommits - statedb.SnapshotCommits)
17591762
blockInsertTimer.UpdateSince(start)
1763+
blockTxsGauge.Update(int64(len(block.Transactions())))
1764+
blockGasUsedGauge.Update(int64(block.GasUsed()))
17601765

17611766
switch status {
17621767
case CanonStatTy:

0 commit comments

Comments
 (0)