You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by ti...@apache.org on 2021/05/10 01:35:00 UTC

[servicecomb-service-center] branch v1.x updated: Fix: add metrics config (#971)

This is an automated email from the ASF dual-hosted git repository.

tianxiaoliang pushed a commit to branch v1.x
in repository https://gitbox.apache.org/repos/asf/servicecomb-service-center.git


The following commit(s) were added to refs/heads/v1.x by this push:
     new a7e2b34  Fix: add metrics config (#971)
a7e2b34 is described below

commit a7e2b34981dbe653b7ce3e26b1117a7af3e86a63
Author: little-cui <su...@qq.com>
AuthorDate: Mon May 10 09:34:52 2021 +0800

    Fix: add metrics config (#971)
---
 server/metric/prometheus/reporter.go | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/server/metric/prometheus/reporter.go b/server/metric/prometheus/reporter.go
index 32cc6df..f089b90 100644
--- a/server/metric/prometheus/reporter.go
+++ b/server/metric/prometheus/reporter.go
@@ -18,6 +18,7 @@ package prometheus
 import (
 	"github.com/apache/servicecomb-service-center/server/metric"
 	dto "github.com/prometheus/client_model/go"
+	"os"
 )
 
 const (
@@ -64,7 +65,9 @@ func (r *APIReporter) toLabels(pairs []*dto.LabelPair) (labels []string) {
 }
 
 func init() {
-	metric.RegisterReporter("rest", NewAPIReporter())
+	if "true" == os.Getenv("METRICS_ENABLE") {
+		metric.RegisterReporter("rest", NewAPIReporter())
+	}
 }
 
 func NewAPIReporter() *APIReporter {