Skip to content

Commit 64356d4

Browse files
committed
Merge branch 'main' of github.com:open-telemetry/opentelemetry-java-instrumentation into indy-reactor-2
2 parents 0295a3d + f44456e commit 64356d4

File tree

8 files changed

+35
-10
lines changed

8 files changed

+35
-10
lines changed

examples/distro/smoke-tests/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ plugins {
55
dependencies {
66
testImplementation("org.testcontainers:testcontainers:1.21.3")
77
testImplementation("com.fasterxml.jackson.core:jackson-databind:2.20.0")
8-
testImplementation("com.google.protobuf:protobuf-java-util:4.32.0")
8+
testImplementation("com.google.protobuf:protobuf-java-util:4.32.1")
99
testImplementation("com.squareup.okhttp3:okhttp:5.1.0")
1010
testImplementation("io.opentelemetry.proto:opentelemetry-proto:1.8.0-alpha")
1111
testImplementation("io.opentelemetry:opentelemetry-api")

examples/extension/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ dependencies {
100100
//All dependencies below are only for tests
101101
testImplementation("org.testcontainers:testcontainers:1.21.3")
102102
testImplementation("com.fasterxml.jackson.core:jackson-databind:2.20.0")
103-
testImplementation("com.google.protobuf:protobuf-java-util:4.32.0")
103+
testImplementation("com.google.protobuf:protobuf-java-util:4.32.1")
104104
testImplementation("com.squareup.okhttp3:okhttp:5.1.0")
105105
testImplementation("io.opentelemetry:opentelemetry-api")
106106
testImplementation("io.opentelemetry.proto:opentelemetry-proto:1.8.0-alpha")

instrumentation/mongo/mongo-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/mongo/v4_0/DefaultConnectionPoolTaskInstrumentation.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ public void transform(TypeTransformer transformer) {
3434
transformer.applyAdviceToMethod(
3535
isConstructor().and(takesArgument(3, Consumer.class)),
3636
this.getClass().getName() + "$TaskArg3Advice");
37+
// since 5.6.0
38+
transformer.applyAdviceToMethod(
39+
isConstructor().and(takesArgument(4, Consumer.class)),
40+
this.getClass().getName() + "$TaskArg4Advice");
3741
}
3842

3943
@SuppressWarnings("unused")
@@ -55,4 +59,14 @@ public static void wrapCallback(
5559
action = new TaskWrapper(Java8BytecodeBridge.currentContext(), action);
5660
}
5761
}
62+
63+
@SuppressWarnings("unused")
64+
public static class TaskArg4Advice {
65+
66+
@Advice.OnMethodEnter(suppress = Throwable.class)
67+
public static void wrapCallback(
68+
@Advice.Argument(value = 4, readOnly = false) Consumer<Object> action) {
69+
action = new TaskWrapper(Java8BytecodeBridge.currentContext(), action);
70+
}
71+
}
5872
}

javaagent-tooling/src/main/java/io/opentelemetry/javaagent/tooling/OpenTelemetryInstaller.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,19 +76,19 @@ private static boolean defaultEnabled(ConfigProvider configProvider) {
7676
return true;
7777
}
7878

79-
String profile =
79+
String mode =
8080
instrumentationConfig
8181
.getStructured("java", empty())
8282
.getStructured("agent", empty())
8383
.getString("instrumentation_mode", "default");
8484

85-
switch (profile) {
85+
switch (mode) {
8686
case "none":
8787
return false;
8888
case "default":
8989
return true;
9090
default:
91-
throw new ConfigurationException("Unknown instrumentation profile: " + profile);
91+
throw new ConfigurationException("Unknown instrumentation mode: " + mode);
9292
}
9393
}
9494

javaagent-tooling/src/test/java/io/opentelemetry/javaagent/tooling/OpenTelemetryInstallerTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,14 @@ void globalOpenTelemetry() {
5151
})
5252
void defaultEnabledInDeclarativeConfigPropertiesBridge(
5353
String propertyValue, boolean expected, boolean fail) {
54-
String profile = propertyValue == null ? "" : "instrumentation_mode: \"" + propertyValue + "\"";
54+
String mode = propertyValue == null ? "" : "instrumentation_mode: \"" + propertyValue + "\"";
5555
String yaml =
5656
"file_format: \"1.0-rc.1\"\n"
5757
+ "instrumentation/development:\n"
5858
+ " java:\n"
5959
+ " agent:\n"
6060
+ " "
61-
+ profile;
61+
+ mode;
6262

6363
Supplier<ConfigProperties> configPropertiesSupplier =
6464
() ->
@@ -71,7 +71,7 @@ void defaultEnabledInDeclarativeConfigPropertiesBridge(
7171
if (fail) {
7272
assertThatCode(() -> configPropertiesSupplier.get())
7373
.isInstanceOf(ConfigurationException.class)
74-
.hasMessage("Unknown instrumentation profile: invalid");
74+
.hasMessage("Unknown instrumentation mode: invalid");
7575
} else {
7676
assertThat(
7777
configPropertiesSupplier

smoke-tests/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ dependencies {
2929
implementation("io.opentelemetry.proto:opentelemetry-proto")
3030
implementation("org.testcontainers:testcontainers")
3131
implementation("com.fasterxml.jackson.core:jackson-databind")
32-
implementation("com.google.protobuf:protobuf-java-util:4.32.0")
32+
implementation("com.google.protobuf:protobuf-java-util:4.32.1")
3333
implementation("io.grpc:grpc-netty-shaded")
3434
implementation("io.grpc:grpc-protobuf")
3535
implementation("io.grpc:grpc-stub")

smoke-tests/src/test/groovy/io/opentelemetry/smoketest/DeclarativeConfigurationSmokeTest.groovy

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,11 @@ class DeclarativeConfigurationSmokeTest extends SmokeTest {
4848
Collection<ExportTraceServiceRequest> traces = waitForTraces()
4949

5050
then: "There is one trace"
51-
traces.size() > 0
51+
traces.size() == 1
52+
53+
then: "There is one span (io.opentelemetry.opentelemetry-instrumentation-annotations-1.16 " +
54+
"is not used, because instrumentation_mode=none)"
55+
getSpanStream(traces).count() == 1
5256

5357
then: "explicitly set attribute is present"
5458
hasResourceAttribute(traces, "service.name", "declarative-config-smoke-test")

smoke-tests/src/test/resources/declarative-config.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,10 @@ resource:
1919
attributes:
2020
- name: service.name
2121
value: declarative-config-smoke-test
22+
23+
instrumentation/development:
24+
java:
25+
agent:
26+
instrumentation_mode: none
27+
tomcat:
28+
enabled: true

0 commit comments

Comments
 (0)