Skip to content

Commit a6d97e3

Browse files
authored
Merge branch 'main' into indy-vertx
2 parents b3f6622 + 900e6e5 commit a6d97e3

File tree

14 files changed

+236
-5
lines changed

14 files changed

+236
-5
lines changed

dependencyManagement/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ val DEPENDENCIES = listOf(
107107
"io.opentelemetry.contrib:opentelemetry-gcp-resources:${otelContribVersion}",
108108
"io.opentelemetry.contrib:opentelemetry-cloudfoundry-resources:${otelContribVersion}",
109109
"io.opentelemetry.contrib:opentelemetry-baggage-processor:${otelContribVersion}",
110-
"io.opentelemetry.proto:opentelemetry-proto:1.7.0-alpha",
110+
"io.opentelemetry.proto:opentelemetry-proto:1.8.0-alpha",
111111
"io.opentelemetry:opentelemetry-extension-annotations:1.18.0", // deprecated, no longer part of bom
112112
"org.assertj:assertj-core:3.27.4",
113113
"org.awaitility:awaitility:4.3.0",

examples/distro/smoke-tests/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ dependencies {
77
testImplementation("com.fasterxml.jackson.core:jackson-databind:2.20.0")
88
testImplementation("com.google.protobuf:protobuf-java-util:4.32.0")
99
testImplementation("com.squareup.okhttp3:okhttp:5.1.0")
10-
testImplementation("io.opentelemetry.proto:opentelemetry-proto:1.7.0-alpha")
10+
testImplementation("io.opentelemetry.proto:opentelemetry-proto:1.8.0-alpha")
1111
testImplementation("io.opentelemetry:opentelemetry-api")
1212

1313
testImplementation("ch.qos.logback:logback-classic:1.5.18")

examples/extension/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ dependencies {
103103
testImplementation("com.google.protobuf:protobuf-java-util:4.32.0")
104104
testImplementation("com.squareup.okhttp3:okhttp:5.1.0")
105105
testImplementation("io.opentelemetry:opentelemetry-api")
106-
testImplementation("io.opentelemetry.proto:opentelemetry-proto:1.7.0-alpha")
106+
testImplementation("io.opentelemetry.proto:opentelemetry-proto:1.8.0-alpha")
107107

108108
testImplementation(enforcedPlatform("org.junit:junit-bom:5.13.4"))
109109
testImplementation("org.junit.jupiter:junit-jupiter-api")

instrumentation/kafka/kafka-clients/kafka-clients-0.11/javaagent/build.gradle.kts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,12 @@ tasks {
6666
dependsOn(testPropagationDisabled, testReceiveSpansDisabled)
6767
}
6868
}
69+
70+
val latestDepTest = findProperty("testLatestDeps") as Boolean
71+
72+
// kafka 4.1 requires java 11
73+
if (latestDepTest) {
74+
otelJava {
75+
minJavaVersionSupported.set(JavaVersion.VERSION_11)
76+
}
77+
}

instrumentation/kafka/kafka-clients/kafka-clients-2.6/library/build.gradle.kts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,12 @@ tasks {
4545
dependsOn(testReceiveSpansDisabled)
4646
}
4747
}
48+
49+
val latestDepTest = findProperty("testLatestDeps") as Boolean
50+
51+
// kafka 4.1 requires java 11
52+
if (latestDepTest) {
53+
otelJava {
54+
minJavaVersionSupported.set(JavaVersion.VERSION_11)
55+
}
56+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/*
2+
* Copyright The OpenTelemetry Authors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
package io.opentelemetry.javaagent.instrumentation.opentelemetryapi;
7+
8+
import static net.bytebuddy.matcher.ElementMatchers.named;
9+
import static net.bytebuddy.matcher.ElementMatchers.returns;
10+
import static net.bytebuddy.matcher.ElementMatchers.takesArgument;
11+
12+
import application.io.opentelemetry.context.Context;
13+
import io.opentelemetry.api.internal.InstrumentationUtil;
14+
import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation;
15+
import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer;
16+
import io.opentelemetry.javaagent.instrumentation.opentelemetryapi.context.AgentContextStorage;
17+
import net.bytebuddy.asm.Advice;
18+
import net.bytebuddy.description.type.TypeDescription;
19+
import net.bytebuddy.matcher.ElementMatcher;
20+
21+
public class InstrumentationUtilInstrumentation implements TypeInstrumentation {
22+
@Override
23+
public ElementMatcher<TypeDescription> typeMatcher() {
24+
return named("application.io.opentelemetry.api.internal.InstrumentationUtil");
25+
}
26+
27+
@Override
28+
public void transform(TypeTransformer transformer) {
29+
transformer.applyAdviceToMethod(
30+
named("shouldSuppressInstrumentation")
31+
.and(takesArgument(0, named("application.io.opentelemetry.context.Context")))
32+
.and(returns(boolean.class)),
33+
this.getClass().getName() + "$ShouldSuppressAdvice");
34+
transformer.applyAdviceToMethod(
35+
named("suppressInstrumentation").and(takesArgument(0, Runnable.class)),
36+
this.getClass().getName() + "$SuppressAdvice");
37+
}
38+
39+
@SuppressWarnings("unused")
40+
public static class ShouldSuppressAdvice {
41+
42+
@Advice.OnMethodEnter(suppress = Throwable.class, skipOn = Advice.OnNonDefaultValue.class)
43+
public static boolean methodEnter() {
44+
return true;
45+
}
46+
47+
@Advice.OnMethodExit(suppress = Throwable.class)
48+
public static void methodExit(
49+
@Advice.Argument(0) Context context, @Advice.Return(readOnly = false) boolean result) {
50+
result =
51+
InstrumentationUtil.shouldSuppressInstrumentation(
52+
AgentContextStorage.getAgentContext(context));
53+
}
54+
}
55+
56+
@SuppressWarnings("unused")
57+
public static class SuppressAdvice {
58+
59+
@Advice.OnMethodEnter(suppress = Throwable.class, skipOn = Advice.OnNonDefaultValue.class)
60+
public static boolean methodEnter(@Advice.Argument(0) Runnable runnable) {
61+
InstrumentationUtil.suppressInstrumentation(runnable);
62+
return true;
63+
}
64+
}
65+
}

instrumentation/opentelemetry-api/opentelemetry-api-1.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/opentelemetryapi/OpenTelemetryApiInstrumentationModule.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ public List<TypeInstrumentation> typeInstrumentations() {
2727
new ContextInstrumentation(),
2828
new ContextStorageWrappersInstrumentation(),
2929
new OpenTelemetryInstrumentation(),
30-
new SpanInstrumentation());
30+
new SpanInstrumentation(),
31+
new InstrumentationUtilInstrumentation());
3132
}
3233

3334
@Override
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
plugins {
2+
id("otel.javaagent-testing")
3+
}
4+
5+
dependencies {
6+
compileOnly(project(":opentelemetry-api-shaded-for-instrumenting", configuration = "shadow"))
7+
implementation(project(":instrumentation:opentelemetry-api:opentelemetry-api-1.0:javaagent"))
8+
testInstrumentation(project(":instrumentation:opentelemetry-api:opentelemetry-api-1.0:javaagent"))
9+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* Copyright The OpenTelemetry Authors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
package io.opentelemetry.javaagent.instrumentation.opentelemetryapi;
7+
8+
import static net.bytebuddy.matcher.ElementMatchers.named;
9+
10+
import application.io.opentelemetry.context.Context;
11+
import io.opentelemetry.api.internal.InstrumentationUtil;
12+
import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation;
13+
import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer;
14+
import io.opentelemetry.javaagent.instrumentation.opentelemetryapi.context.AgentContextStorage;
15+
import net.bytebuddy.asm.Advice;
16+
import net.bytebuddy.description.type.TypeDescription;
17+
import net.bytebuddy.matcher.ElementMatcher;
18+
19+
public class TestInstrumentation implements TypeInstrumentation {
20+
@Override
21+
public ElementMatcher<TypeDescription> typeMatcher() {
22+
return named("io.opentelemetry.javaagent.instrumentation.opentelemetryapi.TestClass");
23+
}
24+
25+
@Override
26+
public void transform(TypeTransformer transformer) {
27+
transformer.applyAdviceToMethod(
28+
named("shouldSuppressInstrumentation"), this.getClass().getName() + "$TestAdvice");
29+
}
30+
31+
@SuppressWarnings("unused")
32+
public static class TestAdvice {
33+
34+
@Advice.OnMethodExit(suppress = Throwable.class)
35+
public static void onExit(
36+
@Advice.Argument(0) Context context, @Advice.Return(readOnly = false) boolean result) {
37+
result =
38+
InstrumentationUtil.shouldSuppressInstrumentation(
39+
AgentContextStorage.getAgentContext(context));
40+
}
41+
}
42+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* Copyright The OpenTelemetry Authors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
package io.opentelemetry.javaagent.instrumentation.opentelemetryapi;
7+
8+
import static java.util.Collections.singletonList;
9+
10+
import com.google.auto.service.AutoService;
11+
import io.opentelemetry.javaagent.extension.instrumentation.InstrumentationModule;
12+
import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation;
13+
import io.opentelemetry.javaagent.extension.instrumentation.internal.ExperimentalInstrumentationModule;
14+
import java.util.List;
15+
16+
@AutoService(InstrumentationModule.class)
17+
public class TestInstrumentationModule extends InstrumentationModule
18+
implements ExperimentalInstrumentationModule {
19+
public TestInstrumentationModule() {
20+
super("test");
21+
}
22+
23+
@Override
24+
public String getModuleGroup() {
25+
return "opentelemetry-api-bridge";
26+
}
27+
28+
@Override
29+
public List<TypeInstrumentation> typeInstrumentations() {
30+
return singletonList(new TestInstrumentation());
31+
}
32+
}

0 commit comments

Comments
 (0)