-
Notifications
You must be signed in to change notification settings - Fork 864
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update to OkHttp 4 and use daemon threads in dispatcher. (#3946)
- Loading branch information
Showing
4 changed files
with
37 additions
and
7 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
30 changes: 30 additions & 0 deletions
30
.../otlp/common/src/main/java/io/opentelemetry/exporter/otlp/internal/okhttp/OkHttpUtil.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.exporter.otlp.internal.okhttp; | ||
|
||
import io.opentelemetry.sdk.internal.DaemonThreadFactory; | ||
import java.util.concurrent.SynchronousQueue; | ||
import java.util.concurrent.ThreadPoolExecutor; | ||
import java.util.concurrent.TimeUnit; | ||
import okhttp3.Dispatcher; | ||
|
||
/** Utilities for OkHttp. */ | ||
public final class OkHttpUtil { | ||
|
||
/** Returns a {@link Dispatcher} using daemon threads, otherwise matching the OkHttp default. */ | ||
public static Dispatcher newDispatcher() { | ||
return new Dispatcher( | ||
new ThreadPoolExecutor( | ||
0, | ||
Integer.MAX_VALUE, | ||
60, | ||
TimeUnit.SECONDS, | ||
new SynchronousQueue<>(), | ||
new DaemonThreadFactory("okhttp-dispatch"))); | ||
} | ||
|
||
private OkHttpUtil() {} | ||
} |