Skip to content

Commit a7540f5

Browse files
jaydelucazeitlinger
authored andcommitted
add test condition
1 parent 94bef10 commit a7540f5

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

instrumentation/spring/spring-boot-autoconfigure/src/main/java/io/opentelemetry/instrumentation/spring/autoconfigure/OpenTelemetryAutoConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public OpenTelemetryAutoConfiguration() {}
7777
@Configuration
7878
@Conditional(OtelEnabled.class)
7979
@ConditionalOnMissingBean(OpenTelemetry.class)
80-
@SuppressWarnings("OtelPrivateConstructorForUtilityClass")
80+
@SuppressWarnings("OtelPrivateConstructorForUtilityClass") // spring uses reflection
8181
static class OpenTelemetrySdkConfig {
8282

8383
@Configuration

instrumentation/spring/spring-boot-autoconfigure/src/testDeclarativeConfig/java/io/opentelemetry/instrumentation/spring/autoconfigure/DeclarativeConfigTest.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,4 +120,15 @@ void shouldLoadInstrumentationWhenExplicitlyEnabled() {
120120
"otel.instrumentation/development.java.spring_web.enabled=true")
121121
.run(context -> assertThat(context).hasBean("otelRestTemplateBeanPostProcessor"));
122122
}
123+
124+
@Test
125+
void shouldNotLoadInstrumentationWhenExplicitlyDisabled() {
126+
this.contextRunner
127+
.withConfiguration(AutoConfigurations.of(SpringWebInstrumentationAutoConfiguration.class))
128+
.withPropertyValues(
129+
"otel.file_format=1.0-rc.1",
130+
"otel.instrumentation/development.java.spring_starter.instrumentation_mode=none",
131+
"otel.instrumentation/development.java.spring_web.enabled=false")
132+
.run(context -> assertThat(context).doesNotHaveBean("otelRestTemplateBeanPostProcessor"));
133+
}
123134
}

0 commit comments

Comments
 (0)