Instrumentation mode cleanup (#14641)

This commit is contained in:
Gregor Zeitlinger 2025-09-12 15:48:13 +02:00 committed by GitHub
parent 2a05236a56
commit 6cbef730e7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 18 additions and 7 deletions

View File

@ -76,19 +76,19 @@ public final class OpenTelemetryInstaller {
return true;
}
String profile =
String mode =
instrumentationConfig
.getStructured("java", empty())
.getStructured("agent", empty())
.getString("instrumentation_mode", "default");
switch (profile) {
switch (mode) {
case "none":
return false;
case "default":
return true;
default:
throw new ConfigurationException("Unknown instrumentation profile: " + profile);
throw new ConfigurationException("Unknown instrumentation mode: " + mode);
}
}

View File

@ -51,14 +51,14 @@ class OpenTelemetryInstallerTest {
})
void defaultEnabledInDeclarativeConfigPropertiesBridge(
String propertyValue, boolean expected, boolean fail) {
String profile = propertyValue == null ? "" : "instrumentation_mode: \"" + propertyValue + "\"";
String mode = propertyValue == null ? "" : "instrumentation_mode: \"" + propertyValue + "\"";
String yaml =
"file_format: \"1.0-rc.1\"\n"
+ "instrumentation/development:\n"
+ " java:\n"
+ " agent:\n"
+ " "
+ profile;
+ mode;
Supplier<ConfigProperties> configPropertiesSupplier =
() ->
@ -71,7 +71,7 @@ class OpenTelemetryInstallerTest {
if (fail) {
assertThatCode(() -> configPropertiesSupplier.get())
.isInstanceOf(ConfigurationException.class)
.hasMessage("Unknown instrumentation profile: invalid");
.hasMessage("Unknown instrumentation mode: invalid");
} else {
assertThat(
configPropertiesSupplier

View File

@ -48,7 +48,11 @@ class DeclarativeConfigurationSmokeTest extends SmokeTest {
Collection<ExportTraceServiceRequest> traces = waitForTraces()
then: "There is one trace"
traces.size() > 0
traces.size() == 1
then: "There is one span (io.opentelemetry.opentelemetry-instrumentation-annotations-1.16 " +
"is not used, because instrumentation_mode=none)"
getSpanStream(traces).count() == 1
then: "explicitly set attribute is present"
hasResourceAttribute(traces, "service.name", "declarative-config-smoke-test")

View File

@ -19,3 +19,10 @@ resource:
attributes:
- name: service.name
value: declarative-config-smoke-test
instrumentation/development:
java:
agent:
instrumentation_mode: none
tomcat:
enabled: true