Files
Will Assis f5e5824bab fix (unified-storage): stop registering unified storage metrics in global state (#101322)
* 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>
2025-02-28 07:39:39 -05:00

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,
}),
}
}