[OTLP/HTTP] Honor Retry-After header when retrying exports #4186
Open
DCchoudhury15 wants to merge 1 commit into
Open
[OTLP/HTTP] Honor Retry-After header when retrying exports #4186DCchoudhury15 wants to merge 1 commit into
DCchoudhury15 wants to merge 1 commit into
Conversation
…-telemetry#4172 Signed-off-by: DCchoudhury15 <divyanshuchoudhury3@gmail.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4186 +/- ##
==========================================
- Coverage 82.99% 82.78% -0.20%
==========================================
Files 406 406
Lines 17260 17308 +48
==========================================
+ Hits 14323 14327 +4
- Misses 2937 2981 +44
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #4172
Changes
The OTLP/HTTP retry logic wasn't respecting the
Retry-Afterresponse header. If a server returned a429or503along withRetry-After, the exporter would ignore that value and always use its configured exponential backoff instead.This PR updates the retry behavior to honor the
Retry-Afterheader as defined in RFC 7231 §7.1.3. Both supported formats are handled:Retry-After: 5)Retry-After: Wed, 21 Oct 2015 07:28:00 GMT)One implementation detail worth noting is that
NextRetryTime()is called from thedoRetrySessionspolling loop afterReleaseResponse()has already cleared the response headers. Because of that, the parsedRetry-Aftervalue is cached inretry_after_time_point_beforeReleaseResponse()is called, andNextRetryTime()uses the cached value instead of trying to parse the headers again.Unit tests are not included yet. I can add them directly to this PR
if the maintainers would like the plan would be to extend the existing
test server fixture with a
/retry-after/endpoint that sets the header,and add two test cases to
ext/test/http/curl_http_test.ccfollowingthe pattern of the existing
ExponentialBackoffRetrytest: one forRetry-After: <delay-seconds>and one forRetry-After: <HTTP-date>.Just let me know and I will push them here.
Known limitation: The HTTP-date parser currently supports only the IMF-fixdate format. The two obsolete date formats (RFC 850 and
asctime) are not supported. Since RFC 7231 specifies IMF-fixdate as the required format for senders, this should not be an issue in practice.CHANGELOG.mdupdated for non-trivial changes