Skip to content

Commit 2354470

Browse files
committed
Merge remote-tracking branch 'upstream/main' into java23
2 parents 72e4e2d + ea8ec35 commit 2354470

File tree

6 files changed

+104
-94
lines changed

6 files changed

+104
-94
lines changed

CONTRIBUTING.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@ https://gradle.com/s/ila4qwp5lcf5s
8989
Opening the build scan link can sometimes take several seconds (it's a large build), but it
9090
typically makes it a lot clearer what's failing.
9191

92+
You can also try the "Explain error" button at the top of the GitHub Actions page,
93+
which often does a reasonable job of parsing the long build log and displaying the important part.
94+
9295
### Draft PRs
9396

9497
Draft PRs are welcome, especially when exploring new ideas or experimenting with a hypothesis.

benchmark-overhead/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ repositories {
1818
dependencies {
1919
implementation(enforcedPlatform("org.junit:junit-bom:5.11.3"))
2020

21-
testImplementation("org.testcontainers:testcontainers:1.20.2")
22-
testImplementation("org.testcontainers:postgresql:1.20.2")
21+
testImplementation("org.testcontainers:testcontainers:1.20.3")
22+
testImplementation("org.testcontainers:postgresql:1.20.3")
2323
testImplementation("org.junit.jupiter:junit-jupiter-api")
2424
testImplementation("org.junit.jupiter:junit-jupiter-params")
2525
testImplementation("com.squareup.okhttp3:okhttp:4.12.0")

examples/distro/smoke-tests/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ plugins {
33
}
44

55
dependencies {
6-
testImplementation("org.testcontainers:testcontainers:1.20.2")
6+
testImplementation("org.testcontainers:testcontainers:1.20.3")
77
testImplementation("com.fasterxml.jackson.core:jackson-databind:2.18.0")
88
testImplementation("com.google.protobuf:protobuf-java-util:3.25.5")
99
testImplementation("com.squareup.okhttp3:okhttp:4.12.0")

examples/extension/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ dependencies {
9999
implementation 'org.apache.commons:commons-lang3:3.17.0'
100100

101101
//All dependencies below are only for tests
102-
testImplementation("org.testcontainers:testcontainers:1.20.2")
102+
testImplementation("org.testcontainers:testcontainers:1.20.3")
103103
testImplementation("com.fasterxml.jackson.core:jackson-databind:2.18.0")
104104
testImplementation("com.google.protobuf:protobuf-java-util:3.25.5")
105105
testImplementation("com.squareup.okhttp3:okhttp:4.12.0")

instrumentation/jaxrs-client/jaxrs-client-1.1-testing/src/test/groovy/JaxRsClientV1Test.groovy

Lines changed: 0 additions & 90 deletions
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
/*
2+
* Copyright The OpenTelemetry Authors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
package io.opentelemetry.javaagent.instrumentation.jaxrsclient;
7+
8+
import com.sun.jersey.api.client.Client;
9+
import com.sun.jersey.api.client.ClientHandlerException;
10+
import com.sun.jersey.api.client.ClientResponse;
11+
import com.sun.jersey.api.client.WebResource;
12+
import com.sun.jersey.api.client.filter.GZIPContentEncodingFilter;
13+
import com.sun.jersey.api.client.filter.LoggingFilter;
14+
import io.opentelemetry.api.common.AttributeKey;
15+
import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension;
16+
import io.opentelemetry.instrumentation.testing.junit.http.AbstractHttpClientTest;
17+
import io.opentelemetry.instrumentation.testing.junit.http.HttpClientInstrumentationExtension;
18+
import io.opentelemetry.instrumentation.testing.junit.http.HttpClientTestOptions;
19+
import io.opentelemetry.instrumentation.testing.junit.http.HttpServerTestOptions;
20+
import io.opentelemetry.semconv.NetworkAttributes;
21+
import java.net.URI;
22+
import java.util.HashSet;
23+
import java.util.Map;
24+
import java.util.Set;
25+
import org.junit.jupiter.api.AfterAll;
26+
import org.junit.jupiter.api.extension.RegisterExtension;
27+
28+
class JaxRsClientV1Test extends AbstractHttpClientTest<WebResource.Builder> {
29+
@RegisterExtension
30+
static final InstrumentationExtension testing = HttpClientInstrumentationExtension.forAgent();
31+
32+
private final Client client = buildClient(false);
33+
private final Client clientWithReadTimeout = buildClient(true);
34+
35+
private static Client buildClient(boolean readTimeout) {
36+
Client client = Client.create();
37+
client.setConnectTimeout((int) CONNECTION_TIMEOUT.toMillis());
38+
if (readTimeout) {
39+
client.setReadTimeout((int) READ_TIMEOUT.toMillis());
40+
}
41+
// Add filters to ensure spans aren't duplicated.
42+
client.addFilter(new LoggingFilter());
43+
client.addFilter(new GZIPContentEncodingFilter());
44+
45+
return client;
46+
}
47+
48+
@Override
49+
protected void configure(HttpClientTestOptions.Builder options) {
50+
options.setTestCircularRedirects(false);
51+
options.setTestNonStandardHttpMethod(false);
52+
options.setTestCallback(false);
53+
options.setHttpAttributes(
54+
serverEndpoint -> {
55+
Set<AttributeKey<?>> attributes =
56+
new HashSet<>(HttpServerTestOptions.DEFAULT_HTTP_ATTRIBUTES);
57+
attributes.remove(NetworkAttributes.NETWORK_PROTOCOL_VERSION);
58+
return attributes;
59+
});
60+
}
61+
62+
@AfterAll
63+
void tearDown() {
64+
client.destroy();
65+
clientWithReadTimeout.destroy();
66+
}
67+
68+
private Client getClient(URI uri) {
69+
if (uri.toString().contains("/read-timeout")) {
70+
return clientWithReadTimeout;
71+
}
72+
return client;
73+
}
74+
75+
@Override
76+
public WebResource.Builder buildRequest(String method, URI uri, Map<String, String> headers) {
77+
WebResource.Builder builder = getClient(uri).resource(uri).getRequestBuilder();
78+
headers.forEach(builder::header);
79+
return builder;
80+
}
81+
82+
@Override
83+
public int sendRequest(
84+
WebResource.Builder builder, String method, URI uri, Map<String, String> headers)
85+
throws Exception {
86+
String body = "POST".equals(method) || "PUT".equals(method) ? "" : null;
87+
try {
88+
return builder.method(method, ClientResponse.class, body).getStatus();
89+
} catch (ClientHandlerException exception) {
90+
Throwable cause = exception.getCause();
91+
if (cause instanceof Exception) {
92+
throw (Exception) cause;
93+
}
94+
throw new IllegalStateException(cause);
95+
}
96+
}
97+
}

0 commit comments

Comments
 (0)