瀏覽代碼

Check if Prometheus is enabled in prometheus.AddGaugeFunc

DarthSim 3 年之前
父節點
當前提交
68ed8708ea
共有 1 個文件被更改,包括 4 次插入0 次删除
  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,