Browse Source

Check if Prometheus is enabled in prometheus.AddGaugeFunc

DarthSim 3 years ago
parent
commit
68ed8708ea
1 changed files with 4 additions and 0 deletions
  1. 4 0
      metrics/prometheus/prometheus.go

+ 4 - 0
metrics/prometheus/prometheus.go

@@ -171,6 +171,10 @@ func SetBufferMaxSize(t string, size int) {
 }
 
 func AddGaugeFunc(name, help string, f func() float64) {
+	if !enabled {
+		return
+	}
+
 	gauge := prometheus.NewGaugeFunc(prometheus.GaugeOpts{
 		Namespace: config.PrometheusNamespace,
 		Name:      name,