Skip to content

Commit 3f643dd

Browse files
committed
create noop metrics system
1 parent 6f129ae commit 3f643dd

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

store/v2/metrics/metrics.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,14 @@ func NewMetrics(labels [][]string) (Metrics, error) {
4545
func (m Metrics) MeasureSince(start time.Time, keys ...string) {
4646
metrics.MeasureSinceWithLabels(keys, start.UTC(), m.Labels)
4747
}
48+
49+
// NoOpMetrics is a no-op implementation of the StoreMetrics interface
50+
type NoOpMetrics struct{}
51+
52+
// NewNoOpMetrics returns a new instance of the NoOpMetrics
53+
func NewNoOpMetrics() NoOpMetrics {
54+
return NoOpMetrics{}
55+
}
56+
57+
// MeasureSince is a no-op implementation of the StoreMetrics interface to avoid time.Now() calls
58+
func (m NoOpMetrics) MeasureSince(start time.Time, keys ...string) {}

store/v2/root/factory.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"cosmossdk.io/store/v2/commitment/mem"
1313
"cosmossdk.io/store/v2/db"
1414
"cosmossdk.io/store/v2/internal"
15+
"cosmossdk.io/store/v2/metrics"
1516
"cosmossdk.io/store/v2/pruning"
1617
)
1718

@@ -127,5 +128,5 @@ func CreateRootStore(opts *FactoryOptions) (store.RootStore, error) {
127128
}
128129

129130
pm := pruning.NewManager(sc, storeOpts.SCPruningOption)
130-
return New(opts.SCRawDB, opts.Logger, sc, pm, nil, nil)
131+
return New(opts.SCRawDB, opts.Logger, sc, pm, nil, metrics.NoOpMetrics{})
131132
}

0 commit comments

Comments
 (0)