Skip to content

Commit

Permalink
x-pack/filebeat/input/httpjson: optimistically accept missing rate li…
Browse files Browse the repository at this point in the history
…mits as no limit

If a rate limit header is not present, do not fail the request, but
rather optimistically assume that we are within limits.
  • Loading branch information
efd6 committed Mar 5, 2024
1 parent 23b9749 commit 5d49c94
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions x-pack/filebeat/input/httpjson/rate_limiter.go
Expand Up @@ -109,7 +109,8 @@ func (r *rateLimiter) getRateLimit(resp *http.Response) (bool, int64, error) {

remaining, _ := r.remaining.Execute(ctx, tr, "rate-limit_remaining", nil, r.log)
if remaining == "" {
return false, 0, errors.New("remaining value is empty")
r.log.Infow("get rate limit", "error", errors.New("remaining value is empty"))
return false, 0, nil
}
m, err := strconv.ParseInt(remaining, 10, 64)
if err != nil {
Expand All @@ -134,7 +135,7 @@ func (r *rateLimiter) getRateLimit(resp *http.Response) (bool, int64, error) {
}
}

r.log.Debugf("Rate Limit: Using active Early Limit: %f", minRemaining)
r.log.Debugf("Rate Limit: Using active Early Limit: %d", minRemaining)
if m > minRemaining {
return false, 0, nil
}
Expand All @@ -146,7 +147,8 @@ func (r *rateLimiter) getRateLimit(resp *http.Response) (bool, int64, error) {

reset, _ := r.reset.Execute(ctx, tr, "rate-limit_reset", nil, r.log)
if reset == "" {
return false, 0, errors.New("reset value is empty")
r.log.Infow("get rate limit", "error", errors.New("reset value is empty"))
return false, 0, nil
}

resumeAt, err := strconv.ParseInt(reset, 10, 64)
Expand Down

0 comments on commit 5d49c94

Please sign in to comment.