mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
app/vmagent/remotewrite: fix rate limiting logic for -remoteWrite.url
This commit is contained in:
parent
7f15cd7161
commit
369f01c738
1 changed files with 2 additions and 3 deletions
|
@ -321,8 +321,7 @@ func (rl *rateLimiter) register(dataLen int, stopCh <-chan struct{}) {
|
||||||
defer rl.mu.Unlock()
|
defer rl.mu.Unlock()
|
||||||
|
|
||||||
for rl.budget <= 0 {
|
for rl.budget <= 0 {
|
||||||
now := time.Now()
|
if d := time.Until(rl.deadline); d > 0 {
|
||||||
if d := rl.deadline.Sub(now); d > 0 {
|
|
||||||
rl.limitReached.Inc()
|
rl.limitReached.Inc()
|
||||||
t := timerpool.Get(d)
|
t := timerpool.Get(d)
|
||||||
select {
|
select {
|
||||||
|
@ -334,7 +333,7 @@ func (rl *rateLimiter) register(dataLen int, stopCh <-chan struct{}) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
rl.budget += limit
|
rl.budget += limit
|
||||||
rl.deadline = now.Add(time.Second)
|
rl.deadline = time.Now().Add(time.Second)
|
||||||
}
|
}
|
||||||
rl.budget -= int64(dataLen)
|
rl.budget -= int64(dataLen)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue