From b89aabd8a76448c8d375c3cc3002d163d5e051cb Mon Sep 17 00:00:00 2001 From: buddh0 Date: Tue, 16 Apr 2024 14:40:57 +0800 Subject: [PATCH] metrics: add blockInsertMgaspsGauge to trace mgasps --- core/blockchain.go | 2 ++ core/blockchain_insert.go | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/core/blockchain.go b/core/blockchain.go index afe2971df6..ff4f66a471 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -71,6 +71,8 @@ var ( justifiedBlockGauge = metrics.NewRegisteredGauge("chain/head/justified", nil) finalizedBlockGauge = metrics.NewRegisteredGauge("chain/head/finalized", nil) + blockInsertMgaspsGauge = metrics.NewRegisteredGauge("chain/insert/mgasps", nil) + chainInfoGauge = metrics.NewRegisteredGaugeInfo("chain/info", nil) accountReadTimer = metrics.NewRegisteredTimer("chain/account/reads", nil) diff --git a/core/blockchain_insert.go b/core/blockchain_insert.go index 4777bff1ac..263074275b 100644 --- a/core/blockchain_insert.go +++ b/core/blockchain_insert.go @@ -58,11 +58,13 @@ func (st *insertStats) report(chain []*types.Block, index int, snapDiffItems, sn end := chain[index] // Assemble the log context and send it to the logger + mgasps := float64(st.usedGas) * 1000 / float64(elapsed) context := []interface{}{ "number", end.Number(), "hash", end.Hash(), "miner", end.Coinbase(), "blocks", st.processed, "txs", txs, "blobs", blobs, "mgas", float64(st.usedGas) / 1000000, - "elapsed", common.PrettyDuration(elapsed), "mgasps", float64(st.usedGas) * 1000 / float64(elapsed), + "elapsed", common.PrettyDuration(elapsed), "mgasps", mgasps, } + blockInsertMgaspsGauge.Update(int64(mgasps)) if timestamp := time.Unix(int64(end.Time()), 0); time.Since(timestamp) > time.Minute { context = append(context, []interface{}{"age", common.PrettyAge(timestamp)}...) }