Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SDTEST-292] Retry HTTP requests on 429 and 5xx responses #243

Merged
merged 2 commits into from
Sep 26, 2024

Conversation

anmarchenko
Copy link
Member

What does this PR do?
Expands failed requests retry logic for HTTP client in this library to be as follows:

  1. If response HTTP code is 5xx, retry up to 3 times with exponential backoff
  2. If response HTTP code is 429, retry up to 3 times, take backoff value from X-RateLimit-Reset response header (stop retrying if backoff value is over 30)
  3. If response HTTP code is 4xx (but not 429), fail immediately without retries
  4. If exception is raised due to network issues, retry up to 3 times with exponential backoff

Motivation
Better handling of transient server errors and rate limit hits: we have some requests failing with 429/503 according to internal telemetry

How to test the change?
Unit tests are provided for each of the above cases

@codecov-commenter
Copy link

codecov-commenter commented Sep 26, 2024

Codecov Report

Attention: Patch coverage is 98.59155% with 1 line in your changes missing coverage. Please review.

Project coverage is 98.88%. Comparing base (570d019) to head (82207ac).

Files with missing lines Patch % Lines
lib/datadog/ci/transport/http.rb 94.44% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #243      +/-   ##
==========================================
- Coverage   98.89%   98.88%   -0.01%     
==========================================
  Files         279      279              
  Lines       13524    13575      +51     
  Branches      620      625       +5     
==========================================
+ Hits        13374    13424      +50     
- Misses        150      151       +1     
Flag Coverage Δ
98.88% <98.59%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@anmarchenko anmarchenko merged commit 7d381d5 into main Sep 26, 2024
30 checks passed
@anmarchenko anmarchenko deleted the anmarchenko/http_client_retries branch September 26, 2024 10:12
@github-actions github-actions bot added this to the 1.8.0 milestone Sep 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants