diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/tracing/BraveAutoConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/tracing/BraveAutoConfiguration.java index 6b00ff79dc..7baa4b22a9 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/tracing/BraveAutoConfiguration.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/tracing/BraveAutoConfiguration.java @@ -236,7 +236,7 @@ public class BraveAutoConfiguration { CorrelationScopeDecorator.Builder mdcCorrelationScopeDecoratorBuilder( ObjectProvider correlationScopeCustomizers) { CorrelationScopeDecorator.Builder builder = MDCScopeDecorator.newBuilder(); - correlationScopeCustomizers.forEach((customizer) -> customizer.customize(builder)); + correlationScopeCustomizers.orderedStream().forEach((customizer) -> customizer.customize(builder)); return builder; } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/tracing/TracingProperties.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/tracing/TracingProperties.java index 500772f276..88fedf9733 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/tracing/TracingProperties.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/tracing/TracingProperties.java @@ -166,7 +166,7 @@ public class TracingProperties { public static class Propagation { /** - * Tracing context propagation types. + * Tracing context propagation type. */ private PropagationType type = PropagationType.W3C; diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/tracing/BaggagePropagationIntegrationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/tracing/BaggagePropagationIntegrationTests.java index 2d4fb67902..82ae93d585 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/tracing/BaggagePropagationIntegrationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/tracing/BaggagePropagationIntegrationTests.java @@ -93,7 +93,7 @@ class BaggagePropagationIntegrationTests { try (Tracer.SpanInScope scope2 = tracer.withSpan(null)) { assertThatMdcContainsUnsetTraceId(); - assertThat(MDC.get(COUNTRY_CODE)).isNullOrEmpty(); + assertThat(MDC.get(COUNTRY_CODE)).isNull(); } assertThat(MDC.get("traceId")).isEqualTo(span.context().traceId()); @@ -103,7 +103,7 @@ class BaggagePropagationIntegrationTests { span.end(); } assertThatMdcContainsUnsetTraceId(); - assertThat(MDC.get(COUNTRY_CODE)).isNullOrEmpty(); + assertThat(MDC.get(COUNTRY_CODE)).isNull(); }); } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/tracing/BraveAutoConfigurationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/tracing/BraveAutoConfigurationTests.java index e629e46c8b..a08c030b2f 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/tracing/BraveAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/tracing/BraveAutoConfigurationTests.java @@ -171,8 +171,11 @@ class BraveAutoConfigurationTests { @Test void shouldSupplyW3CWithoutBaggageByDefaultIfBaggageDisabled() { - this.contextRunner.withPropertyValues("management.tracing.baggage.enabled=false") - .run((context) -> assertThat(context).hasSingleBean(W3CPropagation.class)); + this.contextRunner.withPropertyValues("management.tracing.baggage.enabled=false").run((context) -> { + assertThat(context).hasBean("propagationFactory"); + assertThat(context).hasSingleBean(W3CPropagation.class); + assertThat(context).doesNotHaveBean(BaggagePropagation.FactoryBuilder.class); + }); } @Test @@ -181,6 +184,7 @@ class BraveAutoConfigurationTests { "management.tracing.propagation.type=B3").run((context) -> { assertThat(context).hasBean("propagationFactory"); assertThat(context.getBean(Factory.class).toString()).isEqualTo("B3Propagation"); + assertThat(context).doesNotHaveBean(BaggagePropagation.FactoryBuilder.class); }); } @@ -196,7 +200,7 @@ class BraveAutoConfigurationTests { } @Test - void shouldNotApplyCorrelationFieldsIfBaggageCorrelationEnabled() { + void shouldApplyCorrelationFieldsIfBaggageCorrelationEnabled() { this.contextRunner.withPropertyValues("management.tracing.baggage.correlation.enabled=true", "management.tracing.baggage.correlation.fields=alpha,bravo").run((context) -> { ScopeDecorator scopeDecorator = context.getBean(ScopeDecorator.class); diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/tracing/OpenTelemetryAutoConfigurationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/tracing/OpenTelemetryAutoConfigurationTests.java index 21f3ed7e5c..01cf07b6bd 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/tracing/OpenTelemetryAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/tracing/OpenTelemetryAutoConfigurationTests.java @@ -38,7 +38,6 @@ import io.opentelemetry.sdk.trace.samplers.Sampler; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; -import org.mockito.Answers; import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.test.context.FilteredClassLoader; @@ -152,7 +151,7 @@ class OpenTelemetryAutoConfigurationTests { } @Test - void shouldNotSupplySlf4jBaggageEventListenerBaggageCorrelationDisabled() { + void shouldNotSupplySlf4jBaggageEventListenerWhenBaggageCorrelationDisabled() { this.contextRunner.withPropertyValues("management.tracing.baggage.correlation.enabled=false") .run((context) -> assertThat(context).doesNotHaveBean(Slf4JBaggageEventListener.class)); } @@ -192,16 +191,6 @@ class OpenTelemetryAutoConfigurationTests { .run((context) -> assertThat(context).hasBean("w3cTextMapPropagatorWithoutBaggage")); } - @Test - void shouldSupplyB3PropagationWithoutBaggageWhenBaggageDisabledAndB3PropagationEnabled() { - this.contextRunner.withPropertyValues("management.tracing.baggage.enabled=false", - "management.tracing.propagation.type=B3").run((context) -> { - assertThat(context).hasBean("b3TextMapPropagator"); - assertThat(context).hasSingleBean(B3Propagator.class); - assertThat(context).doesNotHaveBean("w3cTextMapPropagatorWithoutBaggage"); - }); - } - @Configuration(proxyBeanMethods = false) private static class CustomConfiguration { @@ -282,34 +271,4 @@ class OpenTelemetryAutoConfigurationTests { } - @Configuration(proxyBeanMethods = false) - private static class OpenTelemetryConfiguration { - - @Bean - OpenTelemetry openTelemetry() { - return mock(OpenTelemetry.class, Answers.RETURNS_MOCKS); - } - - } - - @Configuration(proxyBeanMethods = false) - private static class ContextPropagatorsConfiguration { - - @Bean - ContextPropagators contextPropagators() { - return mock(ContextPropagators.class, Answers.RETURNS_MOCKS); - } - - } - - @Configuration(proxyBeanMethods = false) - private static class CustomFactoryConfiguration { - - @Bean - TextMapPropagator customPropagationFactory() { - return mock(TextMapPropagator.class); - } - - } - }