Instrumentation mode cleanup (#14641)
This commit is contained in:
parent
2a05236a56
commit
6cbef730e7
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
|
|
|
|||
|
|
@ -19,3 +19,10 @@ resource:
|
|||
attributes:
|
||||
- name: service.name
|
||||
value: declarative-config-smoke-test
|
||||
|
||||
instrumentation/development:
|
||||
java:
|
||||
agent:
|
||||
instrumentation_mode: none
|
||||
tomcat:
|
||||
enabled: true
|
||||
|
|
|
|||
Loading…
Reference in New Issue