Fix bean chicken and egg problem with WavefrontSender
Closes gh-31954
This commit is contained in:
@@ -47,7 +47,7 @@ import org.springframework.context.annotation.Import;
|
||||
@AutoConfiguration(
|
||||
before = { CompositeMeterRegistryAutoConfiguration.class, SimpleMetricsExportAutoConfiguration.class },
|
||||
after = MetricsAutoConfiguration.class)
|
||||
@ConditionalOnBean({ Clock.class, WavefrontSender.class })
|
||||
@ConditionalOnBean(Clock.class)
|
||||
@ConditionalOnClass({ WavefrontMeterRegistry.class, WavefrontSender.class })
|
||||
@ConditionalOnEnabledMetricsExport("wavefront")
|
||||
@EnableConfigurationProperties(WavefrontProperties.class)
|
||||
@@ -62,6 +62,7 @@ public class WavefrontMetricsExportAutoConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
@ConditionalOnBean(WavefrontSender.class)
|
||||
public WavefrontMeterRegistry wavefrontMeterRegistry(WavefrontConfig wavefrontConfig, Clock clock,
|
||||
WavefrontSender wavefrontSender) {
|
||||
return WavefrontMeterRegistry.builder(wavefrontConfig).clock(clock).wavefrontSender(wavefrontSender).build();
|
||||
|
||||
@@ -53,7 +53,7 @@ import org.springframework.core.env.Environment;
|
||||
*/
|
||||
@AutoConfiguration(after = { MetricsAutoConfiguration.class, CompositeMeterRegistryAutoConfiguration.class })
|
||||
@EnableConfigurationProperties(WavefrontProperties.class)
|
||||
@ConditionalOnBean(WavefrontSender.class)
|
||||
@ConditionalOnClass(WavefrontSender.class)
|
||||
@Import(WavefrontSenderConfiguration.class)
|
||||
@ConditionalOnEnabledTracing
|
||||
public class WavefrontTracingAutoConfiguration {
|
||||
@@ -80,6 +80,7 @@ public class WavefrontTracingAutoConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
@ConditionalOnBean(WavefrontSender.class)
|
||||
WavefrontSpanHandler wavefrontSpanHandler(WavefrontProperties properties, WavefrontSender wavefrontSender,
|
||||
SpanMetrics spanMetrics, ApplicationTags applicationTags) {
|
||||
return new WavefrontSpanHandler(properties.getSender().getMaxQueueSize(), wavefrontSender, spanMetrics,
|
||||
|
||||
@@ -58,7 +58,7 @@ class WavefrontTracingAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
void shouldNotSupplyBeansIfWavefrontSenderIsMissing() {
|
||||
this.contextRunner.run((context) -> {
|
||||
this.contextRunner.withClassLoader(new FilteredClassLoader(WavefrontSender.class)).run((context) -> {
|
||||
assertThat(context).doesNotHaveBean(ApplicationTags.class);
|
||||
assertThat(context).doesNotHaveBean(WavefrontSpanHandler.class);
|
||||
assertThat(context).doesNotHaveBean(SpanMetrics.class);
|
||||
|
||||
Reference in New Issue
Block a user