-
Notifications
You must be signed in to change notification settings - Fork 858
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
Interpret timeout zero value as no limit #7023
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -81,11 +81,15 @@ public OkHttpGrpcSender( | |
@Nullable RetryPolicy retryPolicy, | ||
@Nullable SSLContext sslContext, | ||
@Nullable X509TrustManager trustManager) { | ||
int callTimeoutMillis = | ||
(int) Math.min(Duration.ofNanos(timeoutNanos).toMillis(), Integer.MAX_VALUE); | ||
int connectTimeoutMillis = | ||
(int) Math.min(Duration.ofNanos(connectTimeoutNanos).toMillis(), Integer.MAX_VALUE); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Internally, OkHttp converts durations in int type and time unit millis. |
||
OkHttpClient.Builder clientBuilder = | ||
new OkHttpClient.Builder() | ||
.dispatcher(OkHttpUtil.newDispatcher()) | ||
.callTimeout(Duration.ofNanos(timeoutNanos)) | ||
.connectTimeout(Duration.ofNanos(connectTimeoutNanos)); | ||
.callTimeout(Duration.ofMillis(callTimeoutMillis)) | ||
.connectTimeout(Duration.ofMillis(connectTimeoutMillis)); | ||
breedx-splk marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if (retryPolicy != null) { | ||
clientBuilder.addInterceptor( | ||
new RetryInterceptor(retryPolicy, OkHttpGrpcSender::isRetryable)); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,11 +64,15 @@ public OkHttpHttpSender( | |
@Nullable RetryPolicy retryPolicy, | ||
@Nullable SSLContext sslContext, | ||
@Nullable X509TrustManager trustManager) { | ||
int callTimeoutMillis = | ||
(int) Math.min(Duration.ofNanos(timeoutNanos).toMillis(), Integer.MAX_VALUE); | ||
int connectTimeoutMillis = | ||
(int) Math.min(Duration.ofNanos(connectionTimeoutNanos).toMillis(), Integer.MAX_VALUE); | ||
OkHttpClient.Builder builder = | ||
new OkHttpClient.Builder() | ||
.dispatcher(OkHttpUtil.newDispatcher()) | ||
.connectTimeout(Duration.ofNanos(connectionTimeoutNanos)) | ||
.callTimeout(Duration.ofNanos(timeoutNanos)); | ||
.connectTimeout(Duration.ofMillis(connectTimeoutMillis)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same issue as above with |
||
.callTimeout(Duration.ofMillis(callTimeoutMillis)); | ||
|
||
if (proxyOptions != null) { | ||
builder.proxySelector(proxyOptions.getProxySelector()); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to think about negative values while we're at it...or leave for a follow-up effort?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Negative values are rejected upstream of this, e.g.: https://github.com/open-telemetry/opentelemetry-java/blob/main/exporters/otlp/all/src/main/java/io/opentelemetry/exporter/otlp/http/trace/OtlpHttpSpanExporterBuilder.java#L81
We discussed whether to centralize this type of parameter validation in a central place or duplicate it many times in upper layers, and decided on duplicating in upper layers. The idea being, that its much more discoverable for users to discover the requirements of the parameter if the validation is directly in the builder, vs. having to step through an obscure chain of abstractions to reach GrpcExporterBuilder.
We could of course have the checks at multiple layers, but that comes with its own problems of duplication and more edge cases to test if you take a strict view of coverage.