You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The rate limiter only evaluates the rate limit logic if a 429 response is found:
func (r*rateLimiter) execute(ctx context.Context, ffunc() (*http.Response, error)) (*http.Response, error) {
for {
resp, err:=f()
iferr!=nil {
returnnil, fmt.Errorf("failed to read http.response.body: %w", err)
}
ifr==nil||resp.StatusCode==http.StatusOK {
returnresp, nil
}
ifresp.StatusCode!=http.StatusTooManyRequests {
returnnil, fmt.Errorf("http request was unsuccessful with a status code %d", resp.StatusCode)
}
iferr:=r.applyRateLimit(ctx, resp); err!=nil {
returnnil, err
}
}
}
this introduces several issues:
1- Some APIs do not honor the 429 convention and in that case is impossible to trigger a rate limiting event
2- the early_limit option is never evaluated prior to the 429 status, making it useless for its initial intention
The text was updated successfully, but these errors were encountered:
marc-gr
changed the title
x-pack/filebeat/input/httpjson/rate_limiter.go: Rate limit evaluation only happens on 409 responses
x-pack/filebeat/input/httpjson/rate_limiter.go: Rate limit evaluation only happens on 429 responses
Aug 3, 2023
Run the request and return if its successful or fails without StatusTooManyRequests.
If it the response has StatusTooManyRequests it will check config/headers to determine how long to wait. If the checking fails it will return. If checking was successful, after any waiting is complete it will re-enter the for loop and re-run the request.
Drain the request body so the connection can be released, log failures and return the response or error.
Proposed behavior
Draining of the body should be done before the rate limiting, ideally here.
The rate limit checking should be done for all responses, and any wait due should be performed immediately.
After checking/waiting:
the request should be retried if there was an unsuccessful response (including StatusTooManyRequests) or indicated a limit/wait (ideally including cases for which the limit is immediately reset)
other unsuccessful or successful responses should be returned
The rate limiter only evaluates the rate limit logic if a 429 response is found:
this introduces several issues:
1- Some APIs do not honor the 429 convention and in that case is impossible to trigger a rate limiting event
2- the
early_limit
option is never evaluated prior to the 429 status, making it useless for its initial intentionThe text was updated successfully, but these errors were encountered: