mirror of
https://github.com/tendermint/tendermint.git
synced 2026-02-09 05:20:10 +00:00
add basic metrics to the store package
This commit is contained in:
32
store/metrics.gen.go
Normal file
32
store/metrics.gen.go
Normal file
@@ -0,0 +1,32 @@
|
||||
// Code generated by metricsgen. DO NOT EDIT.
|
||||
|
||||
package store
|
||||
|
||||
import (
|
||||
"github.com/go-kit/kit/metrics/discard"
|
||||
prometheus "github.com/go-kit/kit/metrics/prometheus"
|
||||
stdprometheus "github.com/prometheus/client_golang/prometheus"
|
||||
)
|
||||
|
||||
func PrometheusMetrics(namespace string, labelsAndValues ...string) *Metrics {
|
||||
labels := []string{}
|
||||
for i := 0; i < len(labelsAndValues); i += 2 {
|
||||
labels = append(labels, labelsAndValues[i])
|
||||
}
|
||||
return &Metrics{
|
||||
BlockStoreAccessDurationSeconds: prometheus.NewHistogramFrom(stdprometheus.HistogramOpts{
|
||||
Namespace: namespace,
|
||||
Subsystem: MetricsSubsystem,
|
||||
Name: "block_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{
|
||||
BlockStoreAccessDurationSeconds: discard.NewHistogram(),
|
||||
}
|
||||
}
|
||||
20
store/metrics.go
Normal file
20
store/metrics.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package store
|
||||
|
||||
import (
|
||||
"github.com/go-kit/kit/metrics"
|
||||
)
|
||||
|
||||
const (
|
||||
// MetricsSubsystem is a subsystem shared by all metrics exposed by this
|
||||
// package.
|
||||
MetricsSubsystem = "store"
|
||||
)
|
||||
|
||||
//go:generate go run ../scripts/metricsgen -struct=Metrics
|
||||
|
||||
// Metrics contains metrics exposed by this package.
|
||||
type Metrics struct {
|
||||
// The duration of accesses to the state store labeled by which method
|
||||
// was called on the store.
|
||||
BlockStoreAccessDurationSeconds metrics.Histogram `metrics_buckettype:"exp" metrics_bucketsizes:"0.01, 2, 5" metrics_labels:"method"`
|
||||
}
|
||||
@@ -35,6 +35,8 @@ The store can be assumed to contain all contiguous blocks between base and heigh
|
||||
type BlockStore struct {
|
||||
db dbm.DB
|
||||
|
||||
metrics *Metrics
|
||||
|
||||
// mtx guards access to the struct fields listed below it. We rely on the database to enforce
|
||||
// fine-grained concurrency control for its data, and thus this mutex does not apply to
|
||||
// database contents. The only reason for keeping these fields in the struct is that the data
|
||||
|
||||
Reference in New Issue
Block a user