monitor.go 460 字节
Newer Older
Y
Your Name 已提交
1 2 3 4 5 6
package monitor

import (
	"strings"
	"sync"

Y
Your Name 已提交
7 8 9
	"github.com/eolinker/goku-api-gateway/diting"
	goku_labels "github.com/eolinker/goku-api-gateway/goku-labels"
)
Y
Your Name 已提交
10 11

var (
Y
Your Name 已提交
12
	once = sync.Once{}
Y
Your Name 已提交
13 14
)

Y
Your Name 已提交
15 16
//Init init
func Init(cluster string, instance string) {
Y
Your Name 已提交
17 18 19 20

	once.Do(func() {
		constLabels := make(diting.Labels)
		constLabels[goku_labels.Cluster] = cluster
Y
Your Name 已提交
21
		constLabels[goku_labels.Instance] = strings.ReplaceAll(instance, ".", "_")
Y
Your Name 已提交
22 23 24 25

		initCollector(constLabels)
	})
}