From e8452e42fe2ba991f7af5925460c57f1c4ee52ad Mon Sep 17 00:00:00 2001 From: Miguel Angel Rojo Fernandez Date: Tue, 26 Nov 2024 15:55:26 +0000 Subject: [PATCH] added accounts read --- state/metrics.go | 2 +- state/state.go | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/state/metrics.go b/state/metrics.go index f7c1b38a5..312d07702 100644 --- a/state/metrics.go +++ b/state/metrics.go @@ -4,4 +4,4 @@ import ( "github.com/vechain/thor/v2/metrics" ) -var metricAccountCounter = metrics.LazyLoadCounterVec("account_write_count", []string{"type"}) \ No newline at end of file +var metricAccountCounter = metrics.LazyLoadCounterVec("account_write_count", []string{"type", "target"}) \ No newline at end of file diff --git a/state/state.go b/state/state.go index a1eca9479..944123756 100644 --- a/state/state.go +++ b/state/state.go @@ -120,6 +120,7 @@ func (s *State) getCachedObject(addr thor.Address) (*cachedObject, error) { if err != nil { return nil, err } + metricAccountCounter().AddWithLabel(1, map[string]string{"type": "read", "target": "trie"}) co := newCachedObject(s.db, addr, a, am) s.cache[addr] = co return co, nil @@ -131,6 +132,7 @@ func (s *State) getAccount(addr thor.Address) (*Account, error) { if err != nil { return nil, err } + metricAccountCounter().AddWithLabel(1, map[string]string{"type": "read", "target": "stackedmap"}) return v.(*Account), nil } @@ -539,7 +541,7 @@ func (s *State) Stage(newVer trie.Version) (*Stage, error) { } } // If gets here, all tries were committed successfully and the last one contains the updated accounts. - metricAccountCounter().AddWithLabel(int64(len(changes)), map[string]string{"type": "write"}) + metricAccountCounter().AddWithLabel(int64(len(changes)), map[string]string{"type": "write", "target": "trie"}) return nil }, }, nil