From 53cd926797ad873d5e94da364538f87508c60e74 Mon Sep 17 00:00:00 2001 From: William Banfield Date: Mon, 28 Nov 2022 12:26:51 -0500 Subject: [PATCH] add metrics to dbStore --- state/metrics.gen.go | 15 ++++++++++++--- state/metrics.go | 4 ++++ state/store.go | 7 ++++++- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/state/metrics.gen.go b/state/metrics.gen.go index 1ce2c4de1..e0f3d5d65 100644 --- a/state/metrics.gen.go +++ b/state/metrics.gen.go @@ -34,13 +34,22 @@ func PrometheusMetrics(namespace string, labelsAndValues ...string) *Metrics { Name: "validator_set_updates", Help: "ValidatorSetUpdates is the total number of times the application has udated the validator set since process start.", }, labels).With(labelsAndValues...), + StoreAccessDurationSeconds: prometheus.NewHistogramFrom(stdprometheus.HistogramOpts{ + Namespace: namespace, + Subsystem: MetricsSubsystem, + Name: "store_access_duration_seconds", + Help: "The duration of accesses to the state store labeled by which method was called on the store.", + + Buckets: stdprometheus.ExponentialBuckets(0.01, 2, 5), + }, append(labels, "method")).With(labelsAndValues...), } } func NopMetrics() *Metrics { return &Metrics{ - BlockProcessingTime: discard.NewHistogram(), - ConsensusParamUpdates: discard.NewCounter(), - ValidatorSetUpdates: discard.NewCounter(), + BlockProcessingTime: discard.NewHistogram(), + ConsensusParamUpdates: discard.NewCounter(), + ValidatorSetUpdates: discard.NewCounter(), + StoreAccessDurationSeconds: discard.NewHistogram(), } } diff --git a/state/metrics.go b/state/metrics.go index 6c238df76..355f4fd27 100644 --- a/state/metrics.go +++ b/state/metrics.go @@ -24,4 +24,8 @@ type Metrics struct { // ValidatorSetUpdates is the total number of times the application has // udated the validator set since process start. ValidatorSetUpdates metrics.Counter + + // The duration of accesses to the state store labeled by which method + // was called on the store. + StoreAccessDurationSeconds metrics.Histogram `metrics_buckettype:"exp" metrics_bucketsizes:"0.01, 2, 5" metrics_labels:"method"` } diff --git a/state/store.go b/state/store.go index 8503ce687..1f4650e50 100644 --- a/state/store.go +++ b/state/store.go @@ -80,6 +80,8 @@ type Store interface { type dbStore struct { db dbm.DB + metrics *Metrics + StoreOptions } @@ -95,7 +97,10 @@ var _ Store = (*dbStore)(nil) // NewStore creates the dbStore of the state pkg. func NewStore(db dbm.DB, options StoreOptions) Store { - return dbStore{db, options} + return dbStore{ + db: db, + StoreOptions: options, + } } // LoadStateFromDBOrGenesisFile loads the most recent state from the database,