add metrics to dbStore

This commit is contained in:
William Banfield
2022-11-28 12:26:51 -05:00
parent 9d01a6880e
commit 53cd926797
3 changed files with 22 additions and 4 deletions
+12 -3
View File
@@ -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(),
}
}
+4
View File
@@ -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"`
}
+6 -1
View File
@@ -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,