This commit is contained in:
Sergey Cherepanov 2023-06-05 20:39:18 +02:00
parent 0c0a501aad
commit 9d4945c733
No known key found for this signature in database
GPG Key ID: 87F8EDE8FBDF637C

View File

@ -6,6 +6,9 @@ import (
) )
func WithPrometheus(reg *prometheus.Registry, namespace, subsystem string) Option { func WithPrometheus(reg *prometheus.Registry, namespace, subsystem string) Option {
if reg == nil {
return nil
}
if subsystem == "" { if subsystem == "" {
subsystem = "cache" subsystem = "cache"
} }
@ -13,9 +16,7 @@ func WithPrometheus(reg *prometheus.Registry, namespace, subsystem string) Optio
subSplit := strings.Split(subsystem, ".") subSplit := strings.Split(subsystem, ".")
namespace = strings.Join(nameSplit, "_") namespace = strings.Join(nameSplit, "_")
subsystem = strings.Join(subSplit, "_") subsystem = strings.Join(subSplit, "_")
if reg == nil {
return nil
}
return func(cache *oCache) { return func(cache *oCache) {
cache.metrics = &metrics{ cache.metrics = &metrics{
hit: prometheus.NewCounter(prometheus.CounterOpts{ hit: prometheus.NewCounter(prometheus.CounterOpts{