diff options
| author | Chris Lu <chris.lu@gmail.com> | 2020-09-16 01:39:30 -0700 |
|---|---|---|
| committer | Chris Lu <chris.lu@gmail.com> | 2020-09-16 01:39:30 -0700 |
| commit | e861a6a3ab2874261c02c3c42d4450243284b559 (patch) | |
| tree | ba41f7ceb68b2b2c73ae7d7309796f8cd3e244a0 /weed/stats/metrics.go | |
| parent | be54eeb36434e10c624428a2445b61b28a85ca2b (diff) | |
| download | seaweedfs-e861a6a3ab2874261c02c3c42d4450243284b559.tar.xz seaweedfs-e861a6a3ab2874261c02c3c42d4450243284b559.zip | |
simplify metrics configuration logic
Diffstat (limited to 'weed/stats/metrics.go')
| -rw-r--r-- | weed/stats/metrics.go | 19 |
1 files changed, 5 insertions, 14 deletions
diff --git a/weed/stats/metrics.go b/weed/stats/metrics.go index 7ff09a388..f3824728e 100644 --- a/weed/stats/metrics.go +++ b/weed/stats/metrics.go @@ -108,32 +108,23 @@ func init() { } -func LoopPushingMetric(name, instance string, gatherer *prometheus.Registry, fnGetMetricsDest func() (addr string, intervalSeconds int)) { +func LoopPushingMetric(name, instance string, gatherer *prometheus.Registry, addr string, intervalSeconds int) { - if fnGetMetricsDest == nil { + if addr == "" || intervalSeconds == 0 { return } - addr, intervalSeconds := fnGetMetricsDest() pusher := push.New(addr, name).Gatherer(gatherer).Grouping("instance", instance) - currentAddr := addr for { - if currentAddr != "" { - err := pusher.Push() - if err != nil && !strings.HasPrefix(err.Error(), "unexpected status code 200") { - glog.V(0).Infof("could not push metrics to prometheus push gateway %s: %v", addr, err) - } + err := pusher.Push() + if err != nil && !strings.HasPrefix(err.Error(), "unexpected status code 200") { + glog.V(0).Infof("could not push metrics to prometheus push gateway %s: %v", addr, err) } if intervalSeconds <= 0 { intervalSeconds = 15 } time.Sleep(time.Duration(intervalSeconds) * time.Second) - addr, intervalSeconds = fnGetMetricsDest() - if currentAddr != addr { - pusher = push.New(addr, name).Gatherer(gatherer).Grouping("instance", instance) - currentAddr = addr - } } } |
