Skip to content

Commit

Permalink
Add metrics for block building
Browse files Browse the repository at this point in the history
  • Loading branch information
avalonche committed Aug 24, 2024
1 parent ce28546 commit 545a87d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
16 changes: 16 additions & 0 deletions miner/metrics.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package miner

import (
"github.com/ethereum/go-ethereum/metrics"
)

var (
blockProfitHistogram = metrics.NewRegisteredHistogram("miner/block/profit", nil, metrics.NewExpDecaySample(1028, 0.015))
blockProfitGauge = metrics.NewRegisteredGauge("miner/block/profit/gauge", nil)
culmulativeProfitGauge = metrics.NewRegisteredGauge("miner/block/profit/culmulative", nil)

buildBlockTimer = metrics.NewRegisteredTimer("miner/block/build", nil)

gasUsedGauge = metrics.NewRegisteredGauge("miner/block/gasused", nil)
transactionNumGauge = metrics.NewRegisteredGauge("miner/block/txnum", nil)
)
7 changes: 7 additions & 0 deletions miner/payload_building.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,13 @@ func (payload *Payload) update(r *newPayloadResult, elapsed time.Duration) {
}
log.Debug("New payload update", "id", payload.id, "elapsed", common.PrettyDuration(elapsed))

buildBlockTimer.Update(elapsed)
blockProfitHistogram.Update(r.fees.Int64())
blockProfitGauge.Update(r.fees.Int64())
culmulativeProfitGauge.Inc(r.fees.Int64())
gasUsedGauge.Update(int64(r.block.GasUsed()))
transactionNumGauge.Update(int64(len(r.block.Transactions())))

// Ensure the newly provided full block has a higher transaction fee.
// In post-merge stage, there is no uncle reward anymore and transaction
// fee(apart from the mev revenue) is the only indicator for comparison.
Expand Down

0 comments on commit 545a87d

Please sign in to comment.