瀏覽代碼

feat: let different services start prometheus on demand (#1182)

Kevin Wan 3 年之前
父節點
當前提交
a71a210704
共有 1 個文件被更改,包括 4 次插入4 次删除
  1. 4 4
      core/prometheus/agent.go

+ 4 - 4
core/prometheus/agent.go

@@ -23,11 +23,11 @@ func Enabled() bool {
 
 // StartAgent starts a prometheus agent.
 func StartAgent(c Config) {
-	once.Do(func() {
-		if len(c.Host) == 0 {
-			return
-		}
+	if len(c.Host) == 0 {
+		return
+	}
 
+	once.Do(func() {
 		enabled.Set(true)
 		threading.GoSafe(func() {
 			http.Handle(c.Path, promhttp.Handler())