mirror of
https://github.com/grafana/grafana.git
synced 2025-07-31 05:52:16 +08:00

* move prometheus.register for unified storage metrics into metrics.go and do most of the plumbing to get it to work * convert StorageApiMetrics to pointer and check for nil before using it * rename type and variables to something more sensible --------- Co-authored-by: Jean-Philippe Quéméner <jeanphilippe.quemener@grafana.com>
38 lines
1.4 KiB
Go
38 lines
1.4 KiB
Go
package resource
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/grafana/dskit/instrument"
|
|
"github.com/prometheus/client_golang/prometheus"
|
|
"github.com/prometheus/client_golang/prometheus/promauto"
|
|
)
|
|
|
|
type StorageMetrics struct {
|
|
WatchEventLatency *prometheus.HistogramVec
|
|
PollerLatency prometheus.Histogram
|
|
}
|
|
|
|
func ProvideStorageMetrics(reg prometheus.Registerer) *StorageMetrics {
|
|
return &StorageMetrics{
|
|
WatchEventLatency: promauto.With(reg).NewHistogramVec(prometheus.HistogramOpts{
|
|
Namespace: "storage_server",
|
|
Name: "watch_latency_seconds",
|
|
Help: "Time (in seconds) spent waiting for watch events to be sent",
|
|
Buckets: instrument.DefBuckets,
|
|
NativeHistogramBucketFactor: 1.1, // enable native histograms
|
|
NativeHistogramMaxBucketNumber: 160,
|
|
NativeHistogramMinResetDuration: time.Hour,
|
|
}, []string{"resource"}),
|
|
PollerLatency: promauto.With(reg).NewHistogram(prometheus.HistogramOpts{
|
|
Namespace: "storage_server",
|
|
Name: "poller_query_latency_seconds",
|
|
Help: "poller query latency",
|
|
Buckets: instrument.DefBuckets,
|
|
NativeHistogramBucketFactor: 1.1, // enable native histograms
|
|
NativeHistogramMaxBucketNumber: 160,
|
|
NativeHistogramMinResetDuration: time.Hour,
|
|
}),
|
|
}
|
|
}
|