helper/metricsutil: Prevent potential Ticker leak (#10913)
This commit is contained in:
parent
0ad63e5a20
commit
6f3d179635
|
@ -205,6 +205,8 @@ func (p *GaugeCollectionProcess) streamGaugesToSink(values []GaugeLabelValues) {
|
|||
// 1 second / 500 = 2 ms each, so we can send 25 per 50 milliseconds.
|
||||
// That should be one or two packets.
|
||||
sendTick := p.clock.NewTicker(50 * time.Millisecond)
|
||||
defer sendTick.Stop()
|
||||
|
||||
batchSize := 25
|
||||
for i, lv := range values {
|
||||
if i > 0 && i%batchSize == 0 {
|
||||
|
@ -221,7 +223,6 @@ func (p *GaugeCollectionProcess) streamGaugesToSink(values []GaugeLabelValues) {
|
|||
}
|
||||
p.sink.SetGaugeWithLabels(p.key, lv.Value, lv.Labels)
|
||||
}
|
||||
sendTick.Stop()
|
||||
}
|
||||
|
||||
// Run should be called as a goroutine.
|
||||
|
|
Loading…
Reference in New Issue