Skip to content

Commit f94340f

Browse files
authored
Merge pull request #5667 from DataDog/jpbempel/5621-backport
Add UDS support for the debugger by using `OkHttpUtils.buildHttpClient`
2 parents 69ef868 + ef7ecbd commit f94340f

File tree

2 files changed

+16
-21
lines changed

2 files changed

+16
-21
lines changed

dd-java-agent/agent-debugger/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ excludedClassesCoverage += [
1515
'com.datadog.debugger.agent.DebuggerProbe.When.Threshold',
1616
'com.datadog.debugger.agent.DebuggerAgent.ShutdownHook',
1717
'com.datadog.debugger.agent.DebuggerAgent',
18+
'com.datadog.debugger.uploader.BatchUploader',
1819
// too old for this coverage (JDK 1.2)
1920
'antlr.*',
2021
'com.datadog.debugger.util.MoshiSnapshotHelper' // only static classes

dd-java-agent/agent-debugger/src/main/java/com/datadog/debugger/uploader/BatchUploader.java

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44

55
import com.datadog.debugger.util.DebuggerMetrics;
66
import datadog.common.container.ContainerInfo;
7+
import datadog.communication.http.OkHttpUtils;
78
import datadog.trace.api.Config;
89
import datadog.trace.relocate.api.RatelimitedLogger;
910
import datadog.trace.util.AgentThreadFactory;
1011
import java.io.IOException;
1112
import java.time.Duration;
12-
import java.util.Collections;
1313
import java.util.concurrent.ExecutorService;
1414
import java.util.concurrent.Phaser;
1515
import java.util.concurrent.SynchronousQueue;
@@ -19,7 +19,6 @@
1919
import okhttp3.Call;
2020
import okhttp3.Callback;
2121
import okhttp3.ConnectionPool;
22-
import okhttp3.ConnectionSpec;
2322
import okhttp3.Dispatcher;
2423
import okhttp3.HttpUrl;
2524
import okhttp3.MediaType;
@@ -88,26 +87,21 @@ public BatchUploader(Config config) {
8887
// Reusing connections causes non daemon threads to be created which causes agent to prevent app
8988
// from exiting. See https://github.com/square/okhttp/issues/4029 for some details.
9089
ConnectionPool connectionPool = new ConnectionPool(MAX_RUNNING_REQUESTS, 1, TimeUnit.SECONDS);
91-
// Use same timeout everywhere for simplicity
90+
9291
Duration requestTimeout = Duration.ofSeconds(config.getDebuggerUploadTimeout());
93-
OkHttpClient.Builder clientBuilder =
94-
new OkHttpClient.Builder()
95-
.connectTimeout(requestTimeout)
96-
.writeTimeout(requestTimeout)
97-
.readTimeout(requestTimeout)
98-
.callTimeout(requestTimeout)
99-
.dispatcher(new Dispatcher(okHttpExecutorService))
100-
.connectionPool(connectionPool);
101-
102-
if ("http".equals(urlBase.scheme())) {
103-
// force clear text when using http to avoid failures for JVMs without TLS
104-
// see: https://github.com/DataDog/dd-trace-java/pull/1582
105-
clientBuilder.connectionSpecs(Collections.singletonList(ConnectionSpec.CLEARTEXT));
106-
}
107-
client = clientBuilder.build();
108-
client.dispatcher().setMaxRequests(MAX_RUNNING_REQUESTS);
109-
// We are mainly talking to the same(ish) host so we need to raise this limit
110-
client.dispatcher().setMaxRequestsPerHost(MAX_RUNNING_REQUESTS);
92+
client =
93+
OkHttpUtils.buildHttpClient(
94+
config,
95+
new Dispatcher(okHttpExecutorService),
96+
urlBase,
97+
true, /* retry */
98+
MAX_RUNNING_REQUESTS,
99+
null, /* proxyHost */
100+
null, /* proxyPort */
101+
null, /* proxyUsername */
102+
null, /* proxyPassword */
103+
requestTimeout.toMillis());
104+
111105
debuggerMetrics = DebuggerMetrics.getInstance(config);
112106
}
113107

0 commit comments

Comments
 (0)