Remove spring boot autoconfigure resetForTest
MODIFY
instrumentation/spring/spring-boot-autoconfigure/src/test/java/io/opentelemetry/instrumentation/spring/autoconfigure/OpenTelemetryAutoConfigurationTest.java
instrumentation/spring/spring-boot-autoconfigure/src/test/java/io/opentelemetry/instrumentation/spring/autoconfigure/OpenTelemetryAutoConfigurationTest.java
@@ -7,10 +7,8 @@ package io.opentelemetry.instrumentation.spring.autoconfigure;
import static org.assertj.core.api.Assertions.assertThat;
-import io.opentelemetry.api.GlobalOpenTelemetry;
import io.opentelemetry.api.OpenTelemetry;
import io.opentelemetry.sdk.trace.SdkTracerProvider;
-import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.boot.autoconfigure.AutoConfigurations;
@@ -30,11 +28,6 @@ class OpenTelemetryAutoConfigurationTest {
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner();
- @AfterEach
- void tearDown() {
- GlobalOpenTelemetry.resetForTest();
- }
-
@Test
@DisplayName(
"when Application Context contains OpenTelemetry bean should NOT initialize openTelemetry")

MODIFY
instrumentation/spring/spring-boot-autoconfigure/src/test/java/io/opentelemetry/instrumentation/spring/autoconfigure/aspects/TraceAspectAutoConfigurationTest.java
instrumentation/spring/spring-boot-autoconfigure/src/test/java/io/opentelemetry/instrumentation/spring/autoconfigure/aspects/TraceAspectAutoConfigurationTest.java
@@ -7,9 +7,7 @@ package io.opentelemetry.instrumentation.spring.autoconfigure.aspects;
import static org.assertj.core.api.Assertions.assertThat;
-import io.opentelemetry.api.GlobalOpenTelemetry;
import io.opentelemetry.instrumentation.spring.autoconfigure.OpenTelemetryAutoConfiguration;
-import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.boot.autoconfigure.AutoConfigurations;
@@ -24,11 +22,6 @@ public class TraceAspectAutoConfigurationTest {
AutoConfigurations.of(
OpenTelemetryAutoConfiguration.class, TraceAspectAutoConfiguration.class));
- @AfterEach
- void tearDown() {
- GlobalOpenTelemetry.resetForTest();
- }
-
@Test
@DisplayName("when aspects are ENABLED should initialize WithSpanAspect bean")
void aspectsEnabled() {

MODIFY
instrumentation/spring/spring-boot-autoconfigure/src/test/java/io/opentelemetry/instrumentation/spring/autoconfigure/aspects/WithSpanAspectTest.java
instrumentation/spring/spring-boot-autoconfigure/src/test/java/io/opentelemetry/instrumentation/spring/autoconfigure/aspects/WithSpanAspectTest.java
@@ -11,7 +11,6 @@ import static io.opentelemetry.api.trace.SpanKind.SERVER;
import static io.opentelemetry.sdk.testing.assertj.TracesAssert.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import io.opentelemetry.api.GlobalOpenTelemetry;
import io.opentelemetry.api.common.AttributeKey;
import io.opentelemetry.api.common.Attributes;
import io.opentelemetry.api.trace.SpanKind;
@@ -25,7 +24,6 @@ import java.lang.reflect.Method;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;
-import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Nested;
@@ -111,11 +109,6 @@ public class WithSpanAspectTest {
withSpanTester = factory.getProxy();
}
- @AfterAll
- static void tearDown() {
- GlobalOpenTelemetry.resetForTest();
- }
-
@Test
@DisplayName("when method is annotated with @WithSpan should wrap method execution in a Span")
void withSpanWithDefaults() throws Throwable {

MODIFY
instrumentation/spring/spring-boot-autoconfigure/src/test/java/io/opentelemetry/instrumentation/spring/autoconfigure/exporters/JaegerSpanExporterAutoConfigurationTest.java
instrumentation/spring/spring-boot-autoconfigure/src/test/java/io/opentelemetry/instrumentation/spring/autoconfigure/exporters/JaegerSpanExporterAutoConfigurationTest.java
@@ -7,12 +7,10 @@ package io.opentelemetry.instrumentation.spring.autoconfigure.exporters;
import static org.assertj.core.api.Assertions.assertThat;
-import io.opentelemetry.api.GlobalOpenTelemetry;
import io.opentelemetry.exporter.jaeger.JaegerGrpcSpanExporter;
import io.opentelemetry.instrumentation.spring.autoconfigure.OpenTelemetryAutoConfiguration;
import io.opentelemetry.instrumentation.spring.autoconfigure.exporters.jaeger.JaegerSpanExporterAutoConfiguration;
import io.opentelemetry.instrumentation.spring.autoconfigure.exporters.jaeger.JaegerSpanExporterProperties;
-import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.boot.autoconfigure.AutoConfigurations;
@@ -27,11 +25,6 @@ class JaegerSpanExporterAutoConfigurationTest {
AutoConfigurations.of(
OpenTelemetryAutoConfiguration.class, JaegerSpanExporterAutoConfiguration.class));
- @AfterEach
- void tearDown() {
- GlobalOpenTelemetry.resetForTest();
- }
-
@Test
@DisplayName("when exporters are ENABLED should initialize JaegerGrpcSpanExporter bean")
void exportersEnabled() {

MODIFY
instrumentation/spring/spring-boot-autoconfigure/src/test/java/io/opentelemetry/instrumentation/spring/autoconfigure/exporters/LoggingSpanExporterAutoConfigurationTest.java
instrumentation/spring/spring-boot-autoconfigure/src/test/java/io/opentelemetry/instrumentation/spring/autoconfigure/exporters/LoggingSpanExporterAutoConfigurationTest.java
@@ -7,11 +7,9 @@ package io.opentelemetry.instrumentation.spring.autoconfigure.exporters;
import static org.assertj.core.api.Assertions.assertThat;
-import io.opentelemetry.api.GlobalOpenTelemetry;
import io.opentelemetry.exporter.logging.LoggingSpanExporter;
import io.opentelemetry.instrumentation.spring.autoconfigure.OpenTelemetryAutoConfiguration;
import io.opentelemetry.instrumentation.spring.autoconfigure.exporters.logging.LoggingSpanExporterAutoConfiguration;
-import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.boot.autoconfigure.AutoConfigurations;
@@ -27,11 +25,6 @@ class LoggingSpanExporterAutoConfigurationTest {
OpenTelemetryAutoConfiguration.class,
LoggingSpanExporterAutoConfiguration.class));
- @AfterEach
- void tearDown() {
- GlobalOpenTelemetry.resetForTest();
- }
-
@Test
@DisplayName("when exporters are ENABLED should initialize LoggingSpanExporter bean")
void exportersEnabled() {

MODIFY
instrumentation/spring/spring-boot-autoconfigure/src/test/java/io/opentelemetry/instrumentation/spring/autoconfigure/exporters/OtlpGrpcSpanExporterAutoConfigurationTest.java
instrumentation/spring/spring-boot-autoconfigure/src/test/java/io/opentelemetry/instrumentation/spring/autoconfigure/exporters/OtlpGrpcSpanExporterAutoConfigurationTest.java
@@ -7,12 +7,10 @@ package io.opentelemetry.instrumentation.spring.autoconfigure.exporters;
import static org.assertj.core.api.Assertions.assertThat;
-import io.opentelemetry.api.GlobalOpenTelemetry;
import io.opentelemetry.exporter.otlp.trace.OtlpGrpcSpanExporter;
import io.opentelemetry.instrumentation.spring.autoconfigure.OpenTelemetryAutoConfiguration;
import io.opentelemetry.instrumentation.spring.autoconfigure.exporters.otlp.OtlpGrpcSpanExporterAutoConfiguration;
import io.opentelemetry.instrumentation.spring.autoconfigure.exporters.otlp.OtlpGrpcSpanExporterProperties;
-import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.boot.autoconfigure.AutoConfigurations;
@@ -39,11 +37,6 @@ class OtlpGrpcSpanExporterAutoConfigurationTest {
.isNotNull());
}
- @AfterEach
- void tearDown() {
- GlobalOpenTelemetry.resetForTest();
- }
-
@Test
@DisplayName(
"when otel.exporter.otlp properties are set should initialize OtlpGrpcSpanExporterProperties")

MODIFY
instrumentation/spring/spring-boot-autoconfigure/src/test/java/io/opentelemetry/instrumentation/spring/autoconfigure/exporters/ZipkinSpanExporterAutoConfigurationTest.java
instrumentation/spring/spring-boot-autoconfigure/src/test/java/io/opentelemetry/instrumentation/spring/autoconfigure/exporters/ZipkinSpanExporterAutoConfigurationTest.java
@@ -7,12 +7,10 @@ package io.opentelemetry.instrumentation.spring.autoconfigure.exporters;
import static org.assertj.core.api.Assertions.assertThat;
-import io.opentelemetry.api.GlobalOpenTelemetry;
import io.opentelemetry.exporter.zipkin.ZipkinSpanExporter;
import io.opentelemetry.instrumentation.spring.autoconfigure.OpenTelemetryAutoConfiguration;
import io.opentelemetry.instrumentation.spring.autoconfigure.exporters.zipkin.ZipkinSpanExporterAutoConfiguration;
import io.opentelemetry.instrumentation.spring.autoconfigure.exporters.zipkin.ZipkinSpanExporterProperties;
-import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.boot.autoconfigure.AutoConfigurations;
@@ -27,11 +25,6 @@ class ZipkinSpanExporterAutoConfigurationTest {
AutoConfigurations.of(
OpenTelemetryAutoConfiguration.class, ZipkinSpanExporterAutoConfiguration.class));
- @AfterEach
- void tearDown() {
- GlobalOpenTelemetry.resetForTest();
- }
-
@Test
@DisplayName("when exporters are ENABLED should initialize ZipkinSpanExporter bean")
void exportersEnabled() {

MODIFY
instrumentation/spring/spring-boot-autoconfigure/src/test/java/io/opentelemetry/instrumentation/spring/autoconfigure/httpclients/resttemplate/RestTemplateAutoConfigurationTest.java
instrumentation/spring/spring-boot-autoconfigure/src/test/java/io/opentelemetry/instrumentation/spring/autoconfigure/httpclients/resttemplate/RestTemplateAutoConfigurationTest.java
@@ -7,9 +7,7 @@ package io.opentelemetry.instrumentation.spring.autoconfigure.httpclients.restte
import static org.assertj.core.api.Assertions.assertThat;
-import io.opentelemetry.api.GlobalOpenTelemetry;
import io.opentelemetry.instrumentation.spring.autoconfigure.OpenTelemetryAutoConfiguration;
-import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.boot.autoconfigure.AutoConfigurations;
@@ -24,11 +22,6 @@ class RestTemplateAutoConfigurationTest {
AutoConfigurations.of(
OpenTelemetryAutoConfiguration.class, RestTemplateAutoConfiguration.class));
- @AfterEach
- void tearDown() {
- GlobalOpenTelemetry.resetForTest();
- }
-
@Test
@DisplayName("when httpclients are ENABLED should initialize RestTemplateInterceptor bean")
void httpClientsEnabled() {

MODIFY
instrumentation/spring/spring-boot-autoconfigure/src/test/java/io/opentelemetry/instrumentation/spring/autoconfigure/httpclients/webclient/WebClientAutoConfigurationTest.java
instrumentation/spring/spring-boot-autoconfigure/src/test/java/io/opentelemetry/instrumentation/spring/autoconfigure/httpclients/webclient/WebClientAutoConfigurationTest.java
@@ -7,9 +7,7 @@ package io.opentelemetry.instrumentation.spring.autoconfigure.httpclients.webcli
import static org.assertj.core.api.Assertions.assertThat;
-import io.opentelemetry.api.GlobalOpenTelemetry;
import io.opentelemetry.instrumentation.spring.autoconfigure.OpenTelemetryAutoConfiguration;
-import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.boot.autoconfigure.AutoConfigurations;
@@ -24,11 +22,6 @@ class WebClientAutoConfigurationTest {
AutoConfigurations.of(
OpenTelemetryAutoConfiguration.class, WebClientAutoConfiguration.class));
- @AfterEach
- void tearDown() {
- GlobalOpenTelemetry.resetForTest();
- }
-
@Test
@DisplayName("when httpclients are ENABLED should initialize WebClientBeanPostProcessor bean")
void httpClientsEnabled() {

MODIFY
instrumentation/spring/spring-boot-autoconfigure/src/test/java/io/opentelemetry/instrumentation/spring/autoconfigure/propagators/PropagationAutoConfigurationTest.java
instrumentation/spring/spring-boot-autoconfigure/src/test/java/io/opentelemetry/instrumentation/spring/autoconfigure/propagators/PropagationAutoConfigurationTest.java
@@ -7,10 +7,8 @@ package io.opentelemetry.instrumentation.spring.autoconfigure.propagators;
import static org.assertj.core.api.Assertions.assertThat;
-import io.opentelemetry.api.GlobalOpenTelemetry;
import io.opentelemetry.context.propagation.TextMapPropagator;
import io.opentelemetry.instrumentation.spring.autoconfigure.OpenTelemetryAutoConfiguration;
-import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.boot.autoconfigure.AutoConfigurations;
@@ -24,11 +22,6 @@ class PropagationAutoConfigurationTest {
AutoConfigurations.of(
OpenTelemetryAutoConfiguration.class, PropagationAutoConfiguration.class));
- @AfterEach
- void tearDown() {
- GlobalOpenTelemetry.resetForTest();
- }
-
@Test
@DisplayName("when propagation is ENABLED should initialize PropagationAutoConfiguration bean")
void shouldBeConfigured() {

MODIFY
instrumentation/spring/spring-boot-autoconfigure/src/test/java/io/opentelemetry/instrumentation/spring/autoconfigure/propagators/PropagationPropertiesTest.java
instrumentation/spring/spring-boot-autoconfigure/src/test/java/io/opentelemetry/instrumentation/spring/autoconfigure/propagators/PropagationPropertiesTest.java
@@ -7,10 +7,8 @@ package io.opentelemetry.instrumentation.spring.autoconfigure.propagators;
import static org.assertj.core.api.Assertions.assertThat;
-import io.opentelemetry.api.GlobalOpenTelemetry;
import io.opentelemetry.instrumentation.spring.autoconfigure.OpenTelemetryAutoConfiguration;
import java.util.Arrays;
-import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.boot.autoconfigure.AutoConfigurations;
@@ -24,11 +22,6 @@ public class PropagationPropertiesTest {
AutoConfigurations.of(
OpenTelemetryAutoConfiguration.class, PropagationAutoConfiguration.class));
- @AfterEach
- void tearDown() {
- GlobalOpenTelemetry.resetForTest();
- }
-
@Test
@DisplayName("when propagation is SET should set PropagationProperties with given propagators")
void hasType() {

MODIFY
instrumentation/spring/spring-boot-autoconfigure/src/test/java/io/opentelemetry/instrumentation/spring/autoconfigure/webmvc/WebMvcFilterAutoConfigurationTest.java
instrumentation/spring/spring-boot-autoconfigure/src/test/java/io/opentelemetry/instrumentation/spring/autoconfigure/webmvc/WebMvcFilterAutoConfigurationTest.java
@@ -7,10 +7,8 @@ package io.opentelemetry.instrumentation.spring.autoconfigure.webmvc;
import static org.assertj.core.api.Assertions.assertThat;
-import io.opentelemetry.api.GlobalOpenTelemetry;
import io.opentelemetry.instrumentation.spring.autoconfigure.OpenTelemetryAutoConfiguration;
import javax.servlet.Filter;
-import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.boot.autoconfigure.AutoConfigurations;
@@ -24,11 +22,6 @@ class WebMvcFilterAutoConfigurationTest {
AutoConfigurations.of(
OpenTelemetryAutoConfiguration.class, WebMvcFilterAutoConfiguration.class));
- @AfterEach
- void tearDown() {
- GlobalOpenTelemetry.resetForTest();
- }
-
@Test
@DisplayName("when web is ENABLED should initialize WebMvcTracingFilter bean")
void webEnabled() {

Remove spring boot autoconfigure resetForTest (#5566)