diff --git a/pkg/common/prometheus/prometheus.go b/pkg/common/prometheus/prometheus.go index a6b65fee0..2a0d9fe1c 100644 --- a/pkg/common/prometheus/prometheus.go +++ b/pkg/common/prometheus/prometheus.go @@ -28,12 +28,17 @@ func PrometheusHandler() gin.HandlerFunc { func PromeInc(counter prometheus.Counter) { if config.Config.Prometheus.Enable { - counter.Inc() + if counter != nil { + counter.Inc() + } + } } func PromeAdd(counter prometheus.Counter, add int) { if config.Config.Prometheus.Enable { - counter.Add(float64(add)) + if counter != nil { + counter.Add(float64(add)) + } } }