From 409a6e5a766555afdc54066d3d8dcba76f01303d Mon Sep 17 00:00:00 2001 From: Arijit Das Date: Thu, 21 Oct 2021 17:24:58 +0530 Subject: [PATCH 1/2] Report DB metrics --- statediff/service.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/statediff/service.go b/statediff/service.go index 6656168f3..cbb0ee393 100644 --- a/statediff/service.go +++ b/statediff/service.go @@ -22,6 +22,7 @@ import ( "strconv" "sync" "sync/atomic" + "time" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core" @@ -151,6 +152,7 @@ func NewBlockCache(max uint) blockCache { func New(stack *node.Node, ethServ *eth.Ethereum, cfg *ethconfig.Config, params ServiceParams) error { blockChain := ethServ.BlockChain() var indexer ind.Indexer + quitCh := make(chan bool) if params.DBParams != nil { info := nodeinfo.Info{ GenesisBlock: blockChain.Genesis().Hash().Hex(), @@ -169,6 +171,10 @@ func New(stack *node.Node, ethServ *eth.Ethereum, cfg *ethconfig.Config, params if err != nil { return err } + + if metrics.Enabled { + indexer.ReportDBMetrics(10*time.Second, quitCh) + } } workers := params.NumWorkers if workers == 0 { @@ -178,7 +184,7 @@ func New(stack *node.Node, ethServ *eth.Ethereum, cfg *ethconfig.Config, params Mutex: sync.Mutex{}, BlockChain: blockChain, Builder: NewBuilder(blockChain.StateCache()), - QuitChan: make(chan bool), + QuitChan: quitCh, Subscriptions: make(map[common.Hash]map[rpc.ID]Subscription), SubscriptionTypes: make(map[common.Hash]Params), BlockCache: NewBlockCache(workers), -- 2.45.2 From d5f062a2bab82faed98d4a79fd5f9748f79256b4 Mon Sep 17 00:00:00 2001 From: Arijit Das Date: Fri, 22 Oct 2021 19:17:46 +0530 Subject: [PATCH 2/2] Address comments --- statediff/service.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/statediff/service.go b/statediff/service.go index cbb0ee393..1154e4750 100644 --- a/statediff/service.go +++ b/statediff/service.go @@ -172,9 +172,7 @@ func New(stack *node.Node, ethServ *eth.Ethereum, cfg *ethconfig.Config, params return err } - if metrics.Enabled { - indexer.ReportDBMetrics(10*time.Second, quitCh) - } + indexer.ReportDBMetrics(10*time.Second, quitCh) } workers := params.NumWorkers if workers == 0 { -- 2.45.2