Skip to content

Commit

Permalink
added accounts read
Browse files Browse the repository at this point in the history
  • Loading branch information
freemanzMrojo committed Nov 26, 2024
1 parent 2a33805 commit e8452e4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion state/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ import (
"github.com/vechain/thor/v2/metrics"
)

var metricAccountCounter = metrics.LazyLoadCounterVec("account_write_count", []string{"type"})
var metricAccountCounter = metrics.LazyLoadCounterVec("account_write_count", []string{"type", "target"})
4 changes: 3 additions & 1 deletion state/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit e8452e4

Please sign in to comment.