From 53c61362cc5e46012b952df6da83ecee4335573f Mon Sep 17 00:00:00 2001 From: Lauri Tulmin Date: Fri, 6 Sep 2024 11:20:21 +0300 Subject: [PATCH 1/2] Read timeout in jetty http client tests --- .../httpclient/v12_0/AbstractJettyClient12Test.java | 4 +++- .../httpclient/v9_2/AbstractJettyClient9Test.java | 12 +++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/instrumentation/jetty-httpclient/jetty-httpclient-12.0/testing/src/main/java/io/opentelemetry/instrumentation/jetty/httpclient/v12_0/AbstractJettyClient12Test.java b/instrumentation/jetty-httpclient/jetty-httpclient-12.0/testing/src/main/java/io/opentelemetry/instrumentation/jetty/httpclient/v12_0/AbstractJettyClient12Test.java index c4e7a2f5b822..1352269c4030 100644 --- a/instrumentation/jetty-httpclient/jetty-httpclient-12.0/testing/src/main/java/io/opentelemetry/instrumentation/jetty/httpclient/v12_0/AbstractJettyClient12Test.java +++ b/instrumentation/jetty-httpclient/jetty-httpclient-12.0/testing/src/main/java/io/opentelemetry/instrumentation/jetty/httpclient/v12_0/AbstractJettyClient12Test.java @@ -67,7 +67,9 @@ public Request buildRequest(String method, URI uri, Map headers) request.agent("Jetty"); request.method(method); - request.timeout(READ_TIMEOUT.toMillis(), TimeUnit.MILLISECONDS); + if (uri.toString().contains("/read-timeout")) { + request.timeout(READ_TIMEOUT.toMillis(), TimeUnit.MILLISECONDS); + } return request; } diff --git a/instrumentation/jetty-httpclient/jetty-httpclient-9.2/testing/src/main/java/io/opentelemetry/instrumentation/jetty/httpclient/v9_2/AbstractJettyClient9Test.java b/instrumentation/jetty-httpclient/jetty-httpclient-9.2/testing/src/main/java/io/opentelemetry/instrumentation/jetty/httpclient/v9_2/AbstractJettyClient9Test.java index 98a0ca4390f6..8da3a00f3325 100644 --- a/instrumentation/jetty-httpclient/jetty-httpclient-9.2/testing/src/main/java/io/opentelemetry/instrumentation/jetty/httpclient/v9_2/AbstractJettyClient9Test.java +++ b/instrumentation/jetty-httpclient/jetty-httpclient-9.2/testing/src/main/java/io/opentelemetry/instrumentation/jetty/httpclient/v9_2/AbstractJettyClient9Test.java @@ -31,7 +31,7 @@ public abstract class AbstractJettyClient9Test extends AbstractHttpClientTest headers) theClient .newRequest(uri) .method(method) - .agent("Jetty") - .timeout(5000L, TimeUnit.MILLISECONDS); + .agent("Jetty"); headers.forEach(request::header); + + if (uri.toString().contains("/read-timeout")) { + request.timeout(READ_TIMEOUT.toMillis(), TimeUnit.MILLISECONDS); + } else if (uri.toString().contains("192.0.2.1")) { + request.timeout(CONNECTION_TIMEOUT.toMillis(), TimeUnit.MILLISECONDS); + } + return request; } From c1778711de40adfbc2b2a8c0c7b0df19f21001c2 Mon Sep 17 00:00:00 2001 From: Lauri Tulmin Date: Fri, 6 Sep 2024 11:36:26 +0300 Subject: [PATCH 2/2] spotless --- .../jetty/httpclient/v9_2/AbstractJettyClient9Test.java | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/instrumentation/jetty-httpclient/jetty-httpclient-9.2/testing/src/main/java/io/opentelemetry/instrumentation/jetty/httpclient/v9_2/AbstractJettyClient9Test.java b/instrumentation/jetty-httpclient/jetty-httpclient-9.2/testing/src/main/java/io/opentelemetry/instrumentation/jetty/httpclient/v9_2/AbstractJettyClient9Test.java index 8da3a00f3325..e85ca66601c2 100644 --- a/instrumentation/jetty-httpclient/jetty-httpclient-9.2/testing/src/main/java/io/opentelemetry/instrumentation/jetty/httpclient/v9_2/AbstractJettyClient9Test.java +++ b/instrumentation/jetty-httpclient/jetty-httpclient-9.2/testing/src/main/java/io/opentelemetry/instrumentation/jetty/httpclient/v9_2/AbstractJettyClient9Test.java @@ -55,11 +55,7 @@ protected void configure(HttpClientTestOptions.Builder optionsBuilder) { @Override public Request buildRequest(String method, URI uri, Map headers) { HttpClient theClient = uri.getScheme().equalsIgnoreCase("https") ? httpsClient : client; - Request request = - theClient - .newRequest(uri) - .method(method) - .agent("Jetty"); + Request request = theClient.newRequest(uri).method(method).agent("Jetty"); headers.forEach(request::header); if (uri.toString().contains("/read-timeout")) {