Browse Source

Check if Prometheus is enabled in prometheus.AddGaugeFunc

DarthSim 3 năm trước cách đây
mục cha
commit
68ed8708ea
1 tập tin đã thay đổi với 4 bổ sung0 xóa
  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,