MCPcopy
hub / github.com/CodisLabs/codis / startMetricsReporter

Method startMetricsReporter

pkg/proxy/metrics.go:19–40  ·  view source on GitHub ↗
(d time.Duration, do, cleanup func() error)

Source from the content-addressed store, hash-verified

17)
18
19func (p *Proxy) startMetricsReporter(d time.Duration, do, cleanup func() error) {
20 go func() {
21 if cleanup != nil {
22 defer cleanup()
23 }
24 var ticker = time.NewTicker(d)
25 defer ticker.Stop()
26 var delay = &DelayExp2{
27 Min: 1, Max: 15,
28 Unit: time.Second,
29 }
30 for !p.IsClosed() {
31 <-ticker.C
32 if err := do(); err != nil {
33 log.WarnErrorf(err, "report metrics failed")
34 delay.SleepWithCancel(p.IsClosed)
35 } else {
36 delay.Reset()
37 }
38 }
39 }()
40}
41
42func (p *Proxy) startMetricsJson() {
43 server := p.config.MetricsReportServer

Callers 3

startMetricsJsonMethod · 0.95
startMetricsInfluxdbMethod · 0.95
startMetricsStatsdMethod · 0.95

Calls 4

IsClosedMethod · 0.95
WarnErrorfMethod · 0.80
SleepWithCancelMethod · 0.65
ResetMethod · 0.65

Tested by

no test coverage detected