From 9d4945c733d7995058add7f518626e27aba39098 Mon Sep 17 00:00:00 2001 From: Sergey Cherepanov Date: Mon, 5 Jun 2023 20:39:18 +0200 Subject: [PATCH] fix --- app/ocache/metrics.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/ocache/metrics.go b/app/ocache/metrics.go index b520dff2..c2dc04c5 100644 --- a/app/ocache/metrics.go +++ b/app/ocache/metrics.go @@ -6,6 +6,9 @@ import ( ) func WithPrometheus(reg *prometheus.Registry, namespace, subsystem string) Option { + if reg == nil { + return nil + } if subsystem == "" { subsystem = "cache" } @@ -13,9 +16,7 @@ func WithPrometheus(reg *prometheus.Registry, namespace, subsystem string) Optio subSplit := strings.Split(subsystem, ".") namespace = strings.Join(nameSplit, "_") subsystem = strings.Join(subSplit, "_") - if reg == nil { - return nil - } + return func(cache *oCache) { cache.metrics = &metrics{ hit: prometheus.NewCounter(prometheus.CounterOpts{