Skip to content

Commit

Permalink
tweak: Add block trace time metric.
Browse files Browse the repository at this point in the history
  • Loading branch information
tyler-smith committed Oct 6, 2023
1 parent 010a057 commit 32300e6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
11 changes: 11 additions & 0 deletions eth/filters/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,16 @@ var (
},
[]string{},
)

metricsTraceBlockTimer = prometheus.NewHistogramVec(
prometheus.HistogramOpts{
Subsystem: streamSubsystem,
Name: "trace_blocks_duration",
Help: "Trace blocks duration in seconds",
Buckets: []float64{.01, .025, .05, .1, .25, .5, 1, 5, 10, 15},
},
[]string{},
)
)

func init() {
Expand Down Expand Up @@ -185,4 +195,5 @@ func init() {
register(metricsDroppedTxsSent)

register(metricsTraceTxTimer)
register(metricsTraceBlockTimer)
}
2 changes: 2 additions & 0 deletions eth/filters/trace_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ func traceBlock(block *types.Block, chainConfig *params.ChainConfig, chain *core
results = make([]*blocknative.Trace, len(txs))
)

timer := prometheus.NewTimer(metricsTraceBlockTimer.With(nil))
for i, tx := range txs {
msg, err := core.TransactionToMessage(tx, signer, block.BaseFee())
if err != nil {
Expand All @@ -320,6 +321,7 @@ func traceBlock(block *types.Block, chainConfig *params.ChainConfig, chain *core
}
statedb.Finalise(is158)
}
timer.ObserveDuration()

return results, nil
}
Expand Down

0 comments on commit 32300e6

Please sign in to comment.