Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -76,19 +76,19 @@ private static boolean defaultEnabled(ConfigProvider configProvider) {
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);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ void globalOpenTelemetry() {
})
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 =
() ->
Expand All @@ -71,7 +71,7 @@ void defaultEnabledInDeclarativeConfigPropertiesBridge(
if (fail) {
assertThatCode(() -> configPropertiesSupplier.get())
.isInstanceOf(ConfigurationException.class)
.hasMessage("Unknown instrumentation profile: invalid");
.hasMessage("Unknown instrumentation mode: invalid");
} else {
assertThat(
configPropertiesSupplier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
7 changes: 7 additions & 0 deletions smoke-tests/src/test/resources/declarative-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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