From 6a6009827c3d7ab9afffbd8a16fcd333c0731e59 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Wed, 14 Sep 2022 21:42:04 +0800 Subject: [PATCH] prometheus for statistics --- pkg/common/prometheus/prometheus.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) 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)) + } } }