Skip to content

Commit 13f28dc

Browse files
author
Mateusz Rzeszutek
authored
Enable read timeout tests in OkHTTP instrumentation (#4422)
1 parent 538f2a7 commit 13f28dc

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

instrumentation/okhttp/okhttp-2.2/javaagent/src/test/groovy/OkHttp2Test.groovy

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class OkHttp2Test extends HttpClientTest<Request> implements AgentTestTrait {
2525

2626
def setupSpec() {
2727
client.setConnectTimeout(CONNECT_TIMEOUT_MS, TimeUnit.MILLISECONDS)
28+
client.setReadTimeout(READ_TIMEOUT_MS, TimeUnit.MILLISECONDS)
2829
}
2930

3031
@Override
@@ -69,6 +70,7 @@ class OkHttp2Test extends HttpClientTest<Request> implements AgentTestTrait {
6970
switch (uri.toString()) {
7071
case "http://localhost:61/":
7172
case "https://192.0.2.1/":
73+
case resolveAddress("/read-timeout").toString():
7274
attributes.remove(SemanticAttributes.HTTP_FLAVOR)
7375
}
7476

@@ -79,4 +81,9 @@ class OkHttp2Test extends HttpClientTest<Request> implements AgentTestTrait {
7981
boolean testRedirects() {
8082
false
8183
}
84+
85+
@Override
86+
boolean testReadTimeout() {
87+
true
88+
}
8289
}

instrumentation/okhttp/okhttp-3.0/testing/src/main/groovy/io/opentelemetry/instrumentation/okhttp/v3_0/AbstractOkHttp3Test.groovy

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ abstract class AbstractOkHttp3Test extends HttpClientTest<Request> {
3131
Call.Factory client = createCallFactory(
3232
new OkHttpClient.Builder()
3333
.connectTimeout(CONNECT_TIMEOUT_MS, TimeUnit.MILLISECONDS)
34+
.readTimeout(READ_TIMEOUT_MS, TimeUnit.MILLISECONDS)
3435
.protocols(Arrays.asList(Protocol.HTTP_1_1))
3536
.retryOnConnectionFailure(false))
3637

@@ -73,6 +74,11 @@ abstract class AbstractOkHttp3Test extends HttpClientTest<Request> {
7374
false
7475
}
7576

77+
@Override
78+
boolean testReadTimeout() {
79+
true
80+
}
81+
7682
@Override
7783
Set<AttributeKey<?>> httpAttributes(URI uri) {
7884
Set<AttributeKey<?>> extra = [
@@ -85,6 +91,7 @@ abstract class AbstractOkHttp3Test extends HttpClientTest<Request> {
8591
switch (uri.toString()) {
8692
case "http://localhost:61/":
8793
case "https://192.0.2.1/":
94+
case resolveAddress("/read-timeout").toString():
8895
attributes.remove(SemanticAttributes.HTTP_FLAVOR)
8996
}
9097

0 commit comments

Comments
 (0)