From 903e19854d9153d4391b8d17fb433b0bf80f4aae Mon Sep 17 00:00:00 2001 From: ryosuke-hasebe Date: Wed, 17 May 2023 13:54:13 +0900 Subject: [PATCH 1/2] Fix invalid Zipkin Reporter back-off behavior Update `ReporterConfiguration` so that `spanReporter` back off if a `Reporter` bean is defined. Prior to this commit, only `AsyncReporter` beans would be considered. See gh-35455 --- .../tracing/zipkin/ZipkinConfigurations.java | 2 +- .../ZipkinConfigurationsReporterConfigurationTests.java | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/tracing/zipkin/ZipkinConfigurations.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/tracing/zipkin/ZipkinConfigurations.java index f61d4ce2d912..2ff1b2335ca8 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/tracing/zipkin/ZipkinConfigurations.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/tracing/zipkin/ZipkinConfigurations.java @@ -120,7 +120,7 @@ static class ReporterConfiguration { @Bean @ConditionalOnMissingBean @ConditionalOnBean(Sender.class) - AsyncReporter spanReporter(Sender sender, BytesEncoder encoder) { + Reporter spanReporter(Sender sender, BytesEncoder encoder) { return AsyncReporter.builder(sender).build(encoder); } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/tracing/zipkin/ZipkinConfigurationsReporterConfigurationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/tracing/zipkin/ZipkinConfigurationsReporterConfigurationTests.java index 4f5bb4c8e2d7..b09805215d67 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/tracing/zipkin/ZipkinConfigurationsReporterConfigurationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/tracing/zipkin/ZipkinConfigurationsReporterConfigurationTests.java @@ -56,10 +56,11 @@ void shouldNotSupplyReporterIfSenderIsMissing() { @Test void shouldBackOffOnCustomBeans() { - this.contextRunner.withUserConfiguration(CustomConfiguration.class).run((context) -> { - assertThat(context).hasBean("customReporter"); - assertThat(context).hasSingleBean(Reporter.class); - }); + this.contextRunner.withUserConfiguration(SenderConfiguration.class, CustomConfiguration.class) + .run((context) -> { + assertThat(context).hasBean("customReporter"); + assertThat(context).hasSingleBean(Reporter.class); + }); } @Configuration(proxyBeanMethods = false) From 4072588c29b4d445bb38bdc28aed23cdaf0cd56f Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Wed, 17 May 2023 16:38:03 -0700 Subject: [PATCH 2/2] Polish "Fix invalid Zipkin Reporter back-off behavior" See gh-35455 --- .../autoconfigure/tracing/zipkin/ZipkinConfigurations.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/tracing/zipkin/ZipkinConfigurations.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/tracing/zipkin/ZipkinConfigurations.java index 2ff1b2335ca8..8a751eaee784 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/tracing/zipkin/ZipkinConfigurations.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/tracing/zipkin/ZipkinConfigurations.java @@ -118,9 +118,9 @@ ZipkinWebClientSender webClientSender(ZipkinProperties properties, static class ReporterConfiguration { @Bean - @ConditionalOnMissingBean + @ConditionalOnMissingBean(Reporter.class) @ConditionalOnBean(Sender.class) - Reporter spanReporter(Sender sender, BytesEncoder encoder) { + AsyncReporter spanReporter(Sender sender, BytesEncoder encoder) { return AsyncReporter.builder(sender).build(encoder); }