Skip to content

Commit

Permalink
Add metrics for storeV2 (#456)
Browse files Browse the repository at this point in the history
## Describe your changes and provide context
Add two new metrics for StoreV2:
- Add metric to monitor SC commit latency
- Add metric to monitor SS store last commit version

## Testing performed to validate your change
Tested locally and see metrics appear
  • Loading branch information
yzang2019 authored Mar 14, 2024
1 parent 90becb3 commit df756ef
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions storev2/rootmulti/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"sort"
"strings"
"sync"
"time"

"cosmossdk.io/errors"
snapshottypes "github.com/cosmos/cosmos-sdk/snapshots/types"
Expand All @@ -17,6 +18,7 @@ import (
"github.com/cosmos/cosmos-sdk/store/types"
"github.com/cosmos/cosmos-sdk/storev2/commitment"
"github.com/cosmos/cosmos-sdk/storev2/state"
"github.com/cosmos/cosmos-sdk/telemetry"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
protoio "github.com/gogo/protobuf/io"
commonerrors "github.com/sei-protocol/sei-db/common/errors"
Expand Down Expand Up @@ -93,6 +95,8 @@ func (rs *Store) Commit(bumpVersion bool) types.CommitID {
if !bumpVersion {
panic("Commit should always bump version in root multistore")
}
commitStartTime := time.Now()
defer telemetry.MeasureSince(commitStartTime, "storeV2", "sc", "commit", "latency")
if err := rs.flush(); err != nil {
panic(err)
}
Expand Down Expand Up @@ -130,6 +134,7 @@ func (rs *Store) Commit(bumpVersion bool) types.CommitID {
func (rs *Store) StateStoreCommit() {
for pendingChangeSet := range rs.pendingChanges {
version := pendingChangeSet.Version
telemetry.SetGauge(float32(version), "storeV2", "ss", "version")
for _, cs := range pendingChangeSet.Changesets {
if err := rs.ssStore.ApplyChangeset(version, cs); err != nil {
panic(err)
Expand Down

0 comments on commit df756ef

Please sign in to comment.