Explorar el Código

Check if Prometheus is enabled in prometheus.AddGaugeFunc

DarthSim hace 3 años
padre
commit
68ed8708ea
Se han modificado 1 ficheros con 4 adiciones y 0 borrados
  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,