Skip to content

Commit e1f1568

Browse files
authored
Merge branch 'main' into kotlin-ktor
2 parents ce7699b + 187c585 commit e1f1568

File tree

9 files changed

+87
-31
lines changed

9 files changed

+87
-31
lines changed

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.14.1"))
2020

21-
testImplementation(platform("org.testcontainers:testcontainers-bom:2.0.1"))
22-
testImplementation("org.testcontainers:testcontainers:2.0.1")
21+
testImplementation(platform("org.testcontainers:testcontainers-bom:2.0.2"))
22+
testImplementation("org.testcontainers:testcontainers:2.0.2")
2323
testImplementation("org.testcontainers:testcontainers-postgresql")
2424
testImplementation("org.junit.jupiter:junit-jupiter-api")
2525
testImplementation("org.junit.jupiter:junit-jupiter-params")

dependencyManagement/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ val DEPENDENCY_BOMS = listOf(
3232
"org.apache.groovy:groovy-bom:${groovyVersion}",
3333
"io.opentelemetry:opentelemetry-bom:${otelSdkVersion}",
3434
"io.opentelemetry:opentelemetry-bom-alpha:${otelSdkAlphaVersion}",
35-
"org.testcontainers:testcontainers-bom:2.0.1"
35+
"org.testcontainers:testcontainers-bom:2.0.2"
3636
)
3737

3838
val autoServiceVersion = "1.1.1"

examples/distro/smoke-tests/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ plugins {
33
}
44

55
dependencies {
6-
testImplementation("org.testcontainers:testcontainers:2.0.1")
6+
testImplementation("org.testcontainers:testcontainers:2.0.2")
77
testImplementation("com.fasterxml.jackson.core:jackson-databind:2.20.1")
8-
testImplementation("com.google.protobuf:protobuf-java-util:4.33.0")
8+
testImplementation("com.google.protobuf:protobuf-java-util:4.33.1")
99
testImplementation("com.squareup.okhttp3:okhttp:5.3.0")
1010
testImplementation("io.opentelemetry.proto:opentelemetry-proto:1.8.0-alpha")
1111
testImplementation("io.opentelemetry:opentelemetry-api")

examples/extension/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,9 @@ dependencies {
9898
implementation 'org.apache.commons:commons-lang3:3.19.0'
9999

100100
//All dependencies below are only for tests
101-
testImplementation("org.testcontainers:testcontainers:2.0.1")
101+
testImplementation("org.testcontainers:testcontainers:2.0.2")
102102
testImplementation("com.fasterxml.jackson.core:jackson-databind:2.20.1")
103-
testImplementation("com.google.protobuf:protobuf-java-util:4.33.0")
103+
testImplementation("com.google.protobuf:protobuf-java-util:4.33.1")
104104
testImplementation("com.squareup.okhttp3:okhttp:5.3.0")
105105
testImplementation("io.opentelemetry:opentelemetry-api")
106106
testImplementation("io.opentelemetry.proto:opentelemetry-proto:1.8.0-alpha")

instrumentation/spring/spring-core-2.0/javaagent/src/test/java/SimpleAsyncTaskExecutorInstrumentationTest.java

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,14 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

6+
import static org.junit.jupiter.api.Assumptions.assumeTrue;
7+
68
import io.opentelemetry.api.GlobalOpenTelemetry;
79
import io.opentelemetry.api.trace.SpanKind;
810
import io.opentelemetry.api.trace.Tracer;
911
import io.opentelemetry.instrumentation.testing.junit.AgentInstrumentationExtension;
1012
import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension;
13+
import java.lang.reflect.Method;
1114
import java.util.concurrent.Callable;
1215
import java.util.concurrent.CountDownLatch;
1316
import org.junit.jupiter.api.Test;
@@ -22,6 +25,23 @@ class SimpleAsyncTaskExecutorInstrumentationTest {
2225

2326
private static final SimpleAsyncTaskExecutor EXECUTOR = new SimpleAsyncTaskExecutor();
2427

28+
private static final Method submitListenableRunnable;
29+
private static final Method submitListenableCallable;
30+
31+
static {
32+
// removed in spring 7
33+
submitListenableRunnable = findMethod("submitListenable", Runnable.class);
34+
submitListenableCallable = findMethod("submitListenable", Callable.class);
35+
}
36+
37+
private static Method findMethod(String name, Class<?>... parameterTypes) {
38+
try {
39+
return SimpleAsyncTaskExecutor.class.getMethod(name, parameterTypes);
40+
} catch (Exception e) {
41+
return null;
42+
}
43+
}
44+
2545
@Test
2646
void executeRunnable() {
2747
executeTwoTasks(EXECUTOR::execute);
@@ -39,12 +59,14 @@ void submitCallable() {
3959

4060
@Test
4161
void submitListenableRunnable() {
42-
executeTwoTasks(task -> EXECUTOR.submitListenable((Runnable) task));
62+
assumeTrue(submitListenableRunnable != null);
63+
executeTwoTasks(task -> submitListenableRunnable.invoke(EXECUTOR, task));
4364
}
4465

4566
@Test
4667
void submitListenableCallable() {
47-
executeTwoTasks(task -> EXECUTOR.submitListenable((Callable<?>) task));
68+
assumeTrue(submitListenableCallable != null);
69+
executeTwoTasks(task -> submitListenableCallable.invoke(EXECUTOR, task));
4870
}
4971

5072
private static void executeTwoTasks(ThrowingConsumer<AsyncTask> task) {

instrumentation/spring/spring-data/spring-data-3.0/testing/build.gradle.kts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ dependencies {
2020
testImplementation("org.hsqldb:hsqldb:2.0.0")
2121
testImplementation("com.h2database:h2:1.4.197")
2222
testImplementation("io.r2dbc:r2dbc-h2:1.0.0.RELEASE")
23+
24+
// latest version of spring data is not yet compatible with spring 7 yet
25+
latestDepTestLibrary("org.springframework:spring-test:6.+") // documented limitation
2326
}
2427

2528
otelJava {

instrumentation/spring/spring-web/spring-web-3.1/library/src/main/java/io/opentelemetry/instrumentation/spring/web/v3_1/SpringWebHttpAttributesGetter.java

Lines changed: 51 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,40 +13,25 @@
1313
import java.lang.invoke.MethodType;
1414
import java.util.List;
1515
import javax.annotation.Nullable;
16+
import org.springframework.http.HttpHeaders;
1617
import org.springframework.http.HttpRequest;
1718
import org.springframework.http.client.ClientHttpResponse;
1819

1920
enum SpringWebHttpAttributesGetter
2021
implements HttpClientAttributesGetter<HttpRequest, ClientHttpResponse> {
2122
INSTANCE;
2223

23-
@Override
24-
public String getHttpRequestMethod(HttpRequest httpRequest) {
25-
return httpRequest.getMethod().name();
26-
}
27-
28-
@Override
29-
@Nullable
30-
public String getUrlFull(HttpRequest httpRequest) {
31-
return httpRequest.getURI().toString();
32-
}
33-
34-
@Override
35-
public List<String> getHttpRequestHeader(HttpRequest httpRequest, String name) {
36-
return httpRequest.getHeaders().getOrDefault(name, emptyList());
37-
}
38-
3924
@Nullable private static final MethodHandle GET_STATUS_CODE;
40-
4125
@Nullable private static final MethodHandle STATUS_CODE_VALUE;
26+
@Nullable private static final MethodHandle GET_HEADERS;
4227

4328
static {
29+
MethodHandles.Lookup lookup = MethodHandles.publicLookup();
30+
4431
MethodHandle getStatusCode = null;
4532
MethodHandle statusCodeValue = null;
4633
Class<?> httpStatusCodeClass = null;
4734

48-
MethodHandles.Lookup lookup = MethodHandles.publicLookup();
49-
5035
try {
5136
httpStatusCodeClass = Class.forName("org.springframework.http.HttpStatusCode");
5237
} catch (ClassNotFoundException e) {
@@ -73,6 +58,52 @@ public List<String> getHttpRequestHeader(HttpRequest httpRequest, String name) {
7358

7459
GET_STATUS_CODE = getStatusCode;
7560
STATUS_CODE_VALUE = statusCodeValue;
61+
62+
// since spring web 7.0
63+
MethodHandle methodHandle =
64+
findGetHeadersMethod(MethodType.methodType(List.class, String.class, List.class));
65+
if (methodHandle == null) {
66+
// up to spring web 7.0
67+
methodHandle =
68+
findGetHeadersMethod(MethodType.methodType(Object.class, Object.class, Object.class));
69+
}
70+
GET_HEADERS = methodHandle;
71+
}
72+
73+
private static MethodHandle findGetHeadersMethod(MethodType methodType) {
74+
try {
75+
return MethodHandles.lookup().findVirtual(HttpHeaders.class, "getOrDefault", methodType);
76+
} catch (Throwable t) {
77+
return null;
78+
}
79+
}
80+
81+
@Override
82+
public String getHttpRequestMethod(HttpRequest httpRequest) {
83+
return httpRequest.getMethod().name();
84+
}
85+
86+
@Override
87+
@Nullable
88+
public String getUrlFull(HttpRequest httpRequest) {
89+
return httpRequest.getURI().toString();
90+
}
91+
92+
@Override
93+
public List<String> getHttpRequestHeader(HttpRequest httpRequest, String name) {
94+
return getHeader(httpRequest.getHeaders(), name);
95+
}
96+
97+
@SuppressWarnings("unchecked") // casting MethodHandle.invoke result
98+
private static List<String> getHeader(HttpHeaders headers, String name) {
99+
if (GET_HEADERS != null) {
100+
try {
101+
return (List<String>) GET_HEADERS.invoke(headers, name, emptyList());
102+
} catch (Throwable t) {
103+
// ignore
104+
}
105+
}
106+
return emptyList();
76107
}
77108

78109
@Override
@@ -94,7 +125,7 @@ public Integer getHttpResponseStatusCode(
94125
@Override
95126
public List<String> getHttpResponseHeader(
96127
HttpRequest httpRequest, ClientHttpResponse clientHttpResponse, String name) {
97-
return clientHttpResponse.getHeaders().getOrDefault(name, emptyList());
128+
return getHeader(clientHttpResponse.getHeaders(), name);
98129
}
99130

100131
@Override

smoke-tests/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ dependencies {
2424
implementation("io.opentelemetry.proto:opentelemetry-proto")
2525
implementation("org.testcontainers:testcontainers")
2626
implementation("com.fasterxml.jackson.core:jackson-databind")
27-
implementation("com.google.protobuf:protobuf-java-util:4.33.0")
27+
implementation("com.google.protobuf:protobuf-java-util:4.33.1")
2828
implementation("io.grpc:grpc-netty-shaded")
2929
implementation("io.grpc:grpc-protobuf")
3030
implementation("io.grpc:grpc-stub")

testing/dependencies-shaded-for-testing/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ dependencies {
99
implementation("com.linecorp.armeria:armeria-junit5:1.33.4")
1010
implementation("com.google.errorprone:error_prone_annotations")
1111
implementation("io.opentelemetry.proto:opentelemetry-proto")
12-
implementation("com.google.protobuf:protobuf-java-util:4.33.0")
12+
implementation("com.google.protobuf:protobuf-java-util:4.33.1")
1313
implementation("com.github.tomakehurst:wiremock-jre8:2.35.2")
1414
implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml")
1515
// we'll replace caffeine shaded in armeria with a later version that doesn't use Unsafe. Caffeine

0 commit comments

Comments
 (0)