Skip to content

Commit 6cbef73

Browse files
authored
Instrumentation mode cleanup (#14641)
1 parent 2a05236 commit 6cbef73

File tree

4 files changed

+18
-7
lines changed

4 files changed

+18
-7
lines changed

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/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)