mirror of https://github.com/prometheus/prometheus
Review feedback.
parent
97a5fc8cbb
commit
fdb574b608
|
@ -430,14 +430,15 @@ func (s *shards) runShard(i int) {
|
||||||
pendingSamples := model.Samples{}
|
pendingSamples := model.Samples{}
|
||||||
|
|
||||||
timer := time.NewTimer(s.qm.cfg.BatchSendDeadline)
|
timer := time.NewTimer(s.qm.cfg.BatchSendDeadline)
|
||||||
defer func() {
|
stop := func() {
|
||||||
if !timer.Stop() {
|
if !timer.Stop() {
|
||||||
select {
|
select {
|
||||||
case <-timer.C:
|
case <-timer.C:
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}()
|
}
|
||||||
|
defer stop()
|
||||||
|
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
|
@ -454,16 +455,11 @@ func (s *shards) runShard(i int) {
|
||||||
queueLength.WithLabelValues(s.qm.queueName).Dec()
|
queueLength.WithLabelValues(s.qm.queueName).Dec()
|
||||||
pendingSamples = append(pendingSamples, sample)
|
pendingSamples = append(pendingSamples, sample)
|
||||||
|
|
||||||
for len(pendingSamples) >= s.qm.cfg.MaxSamplesPerSend {
|
if len(pendingSamples) >= s.qm.cfg.MaxSamplesPerSend {
|
||||||
s.sendSamples(pendingSamples[:s.qm.cfg.MaxSamplesPerSend])
|
s.sendSamples(pendingSamples[:s.qm.cfg.MaxSamplesPerSend])
|
||||||
pendingSamples = pendingSamples[s.qm.cfg.MaxSamplesPerSend:]
|
pendingSamples = pendingSamples[s.qm.cfg.MaxSamplesPerSend:]
|
||||||
|
|
||||||
if !timer.Stop() {
|
stop()
|
||||||
select {
|
|
||||||
case <-timer.C:
|
|
||||||
default:
|
|
||||||
}
|
|
||||||
}
|
|
||||||
timer.Reset(s.qm.cfg.BatchSendDeadline)
|
timer.Reset(s.qm.cfg.BatchSendDeadline)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -472,6 +468,7 @@ func (s *shards) runShard(i int) {
|
||||||
s.sendSamples(pendingSamples)
|
s.sendSamples(pendingSamples)
|
||||||
pendingSamples = pendingSamples[:0]
|
pendingSamples = pendingSamples[:0]
|
||||||
}
|
}
|
||||||
|
timer.Reset(s.qm.cfg.BatchSendDeadline)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue