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

JdkHttpSender should retry on connect exceptions #5867

Merged
merged 4 commits into from
Oct 23, 2023

Conversation

jack-berg
Copy link
Member

Fixes a TODO in JdkHttpSender by ensuring that it retries on connect exceptions.

Thanks to @mikelaspina for the report!

@jack-berg jack-berg requested a review from a team as a code owner September 29, 2023 18:47
@codecov
Copy link

codecov bot commented Sep 29, 2023

Codecov Report

Attention: 7 lines in your changes are missing coverage. Please review.

Files Coverage Δ
...ry/exporter/sender/jdk/internal/JdkHttpSender.java 89.38% <83.33%> (+2.01%) ⬆️

... and 38 files with indirect coverage changes

📢 Thoughts on this report? Let us know!.

Copy link
Contributor

@breedx-splk breedx-splk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, just had a small question.

Comment on lines +47 to +58
new JdkHttpSender(
mockHttpClient,
"http://10.255.255.1", // Connecting to a non-routable IP address to trigger connection
// timeout
false,
"text/plain",
Duration.ofSeconds(10).toNanos(),
Collections::emptyMap,
RetryPolicy.builder()
.setMaxAttempts(2)
.setInitialBackoff(Duration.ofMillis(1))
.build());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For anther PR of course, but maybe the JdkHttpSender is ready for a builder. :)

throw new IllegalStateException(e);
} finally {
byteBufferPool.resetPool();
}
}

private static boolean isRetryableException(IOException throwable) {
return throwable instanceof HttpConnectTimeoutException;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have we thought about expanding the scope a bit to include the parent type HttpTimeoutException? This could allow for retries for send timeouts beyond just the connection timeout.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So for OkHttp, there are settings for connectTimeout, readTimeout, and writeTimeout. When these settings are exceeded, you get a corresponding timeout.

For JDK HttpClient, there's only a connectTimeout setting. So I'm not actually sure what the read / write timeout settings are or how to reproduce one of these things in tests to ensure we're doing the right thing.

With that said, I do think we want to retry in all timeout scenarios, so I'm going to expand the criteria of retryable exceptions to include any HttpTimeoutException.

@jack-berg jack-berg merged commit e06d35a into open-telemetry:main Oct 23, 2023
18 checks passed
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.

None yet

3 participants