|
|
|
|
@ -20,11 +20,10 @@ import java.util.List;
@@ -20,11 +20,10 @@ import java.util.List;
|
|
|
|
|
|
|
|
|
|
import io.micrometer.tracing.Tracer; |
|
|
|
|
import io.micrometer.tracing.handler.DefaultTracingObservationHandler; |
|
|
|
|
import io.micrometer.tracing.handler.HttpClientTracingObservationHandler; |
|
|
|
|
import io.micrometer.tracing.handler.HttpServerTracingObservationHandler; |
|
|
|
|
import io.micrometer.tracing.handler.PropagatingReceiverTracingObservationHandler; |
|
|
|
|
import io.micrometer.tracing.handler.PropagatingSenderTracingObservationHandler; |
|
|
|
|
import io.micrometer.tracing.handler.TracingObservationHandler; |
|
|
|
|
import io.micrometer.tracing.http.HttpClientHandler; |
|
|
|
|
import io.micrometer.tracing.http.HttpServerHandler; |
|
|
|
|
import io.micrometer.tracing.propagation.Propagator; |
|
|
|
|
import org.junit.jupiter.api.Test; |
|
|
|
|
|
|
|
|
|
import org.springframework.boot.autoconfigure.AutoConfigurations; |
|
|
|
|
@ -48,26 +47,26 @@ class MicrometerTracingAutoConfigurationTests {
@@ -48,26 +47,26 @@ class MicrometerTracingAutoConfigurationTests {
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
void shouldSupplyBeans() { |
|
|
|
|
this.contextRunner.withUserConfiguration(TracerConfiguration.class, HttpClientHandlerConfiguration.class, |
|
|
|
|
HttpServerHandlerConfiguration.class).run((context) -> { |
|
|
|
|
this.contextRunner.withUserConfiguration(TracerConfiguration.class, PropagatorConfiguration.class) |
|
|
|
|
.run((context) -> { |
|
|
|
|
assertThat(context).hasSingleBean(DefaultTracingObservationHandler.class); |
|
|
|
|
assertThat(context).hasSingleBean(HttpServerTracingObservationHandler.class); |
|
|
|
|
assertThat(context).hasSingleBean(HttpClientTracingObservationHandler.class); |
|
|
|
|
assertThat(context).hasSingleBean(PropagatingReceiverTracingObservationHandler.class); |
|
|
|
|
assertThat(context).hasSingleBean(PropagatingSenderTracingObservationHandler.class); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
@SuppressWarnings("rawtypes") |
|
|
|
|
void shouldSupplyBeansInCorrectOrder() { |
|
|
|
|
this.contextRunner.withUserConfiguration(TracerConfiguration.class, HttpClientHandlerConfiguration.class, |
|
|
|
|
HttpServerHandlerConfiguration.class).run((context) -> { |
|
|
|
|
this.contextRunner.withUserConfiguration(TracerConfiguration.class, PropagatorConfiguration.class) |
|
|
|
|
.run((context) -> { |
|
|
|
|
List<TracingObservationHandler> tracingObservationHandlers = context |
|
|
|
|
.getBeanProvider(TracingObservationHandler.class).orderedStream().toList(); |
|
|
|
|
assertThat(tracingObservationHandlers).hasSize(3); |
|
|
|
|
assertThat(tracingObservationHandlers.get(0)) |
|
|
|
|
.isInstanceOf(HttpServerTracingObservationHandler.class); |
|
|
|
|
.isInstanceOf(PropagatingReceiverTracingObservationHandler.class); |
|
|
|
|
assertThat(tracingObservationHandlers.get(1)) |
|
|
|
|
.isInstanceOf(HttpClientTracingObservationHandler.class); |
|
|
|
|
.isInstanceOf(PropagatingSenderTracingObservationHandler.class); |
|
|
|
|
assertThat(tracingObservationHandlers.get(2)).isInstanceOf(DefaultTracingObservationHandler.class); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
@ -77,10 +76,10 @@ class MicrometerTracingAutoConfigurationTests {
@@ -77,10 +76,10 @@ class MicrometerTracingAutoConfigurationTests {
|
|
|
|
|
this.contextRunner.withUserConfiguration(CustomConfiguration.class).run((context) -> { |
|
|
|
|
assertThat(context).hasBean("customDefaultTracingObservationHandler"); |
|
|
|
|
assertThat(context).hasSingleBean(DefaultTracingObservationHandler.class); |
|
|
|
|
assertThat(context).hasBean("customHttpServerTracingObservationHandler"); |
|
|
|
|
assertThat(context).hasSingleBean(HttpServerTracingObservationHandler.class); |
|
|
|
|
assertThat(context).hasBean("customHttpClientTracingObservationHandler"); |
|
|
|
|
assertThat(context).hasSingleBean(HttpClientTracingObservationHandler.class); |
|
|
|
|
assertThat(context).hasBean("customPropagatingReceiverTracingObservationHandler"); |
|
|
|
|
assertThat(context).hasSingleBean(PropagatingReceiverTracingObservationHandler.class); |
|
|
|
|
assertThat(context).hasBean("customPropagatingSenderTracingObservationHandler"); |
|
|
|
|
assertThat(context).hasSingleBean(PropagatingSenderTracingObservationHandler.class); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -88,43 +87,35 @@ class MicrometerTracingAutoConfigurationTests {
@@ -88,43 +87,35 @@ class MicrometerTracingAutoConfigurationTests {
|
|
|
|
|
void shouldNotSupplyBeansIfMicrometerIsMissing() { |
|
|
|
|
this.contextRunner.withClassLoader(new FilteredClassLoader("io.micrometer")).run((context) -> { |
|
|
|
|
assertThat(context).doesNotHaveBean(DefaultTracingObservationHandler.class); |
|
|
|
|
assertThat(context).doesNotHaveBean(HttpServerTracingObservationHandler.class); |
|
|
|
|
assertThat(context).doesNotHaveBean(HttpClientTracingObservationHandler.class); |
|
|
|
|
assertThat(context).doesNotHaveBean(PropagatingReceiverTracingObservationHandler.class); |
|
|
|
|
assertThat(context).doesNotHaveBean(PropagatingSenderTracingObservationHandler.class); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
void shouldNotSupplyBeansIfTracerIsMissing() { |
|
|
|
|
this.contextRunner |
|
|
|
|
.withUserConfiguration(HttpServerHandlerConfiguration.class, HttpClientHandlerConfiguration.class) |
|
|
|
|
.run((context) -> { |
|
|
|
|
assertThat(context).doesNotHaveBean(DefaultTracingObservationHandler.class); |
|
|
|
|
assertThat(context).doesNotHaveBean(HttpServerTracingObservationHandler.class); |
|
|
|
|
assertThat(context).doesNotHaveBean(HttpClientTracingObservationHandler.class); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
void shouldNotSupplyBeansIfHttpClientHandlerIsMissing() { |
|
|
|
|
this.contextRunner.withUserConfiguration(TracerConfiguration.class, HttpServerHandlerConfiguration.class) |
|
|
|
|
.run((context) -> assertThat(context).doesNotHaveBean(HttpClientTracingObservationHandler.class)); |
|
|
|
|
this.contextRunner.withUserConfiguration(PropagatorConfiguration.class).run((context) -> { |
|
|
|
|
assertThat(context).doesNotHaveBean(DefaultTracingObservationHandler.class); |
|
|
|
|
assertThat(context).doesNotHaveBean(PropagatingReceiverTracingObservationHandler.class); |
|
|
|
|
assertThat(context).doesNotHaveBean(PropagatingSenderTracingObservationHandler.class); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
void shouldNotSupplyBeansIfHttpServerHandlerIsMissing() { |
|
|
|
|
this.contextRunner.withUserConfiguration(TracerConfiguration.class, HttpClientHandlerConfiguration.class) |
|
|
|
|
.run((context) -> assertThat(context).doesNotHaveBean(HttpServerTracingObservationHandler.class)); |
|
|
|
|
void shouldNotSupplyBeansIfPropagatorIsMissing() { |
|
|
|
|
this.contextRunner.withUserConfiguration(TracerConfiguration.class).run((context) -> { |
|
|
|
|
assertThat(context).doesNotHaveBean(PropagatingSenderTracingObservationHandler.class); |
|
|
|
|
assertThat(context).doesNotHaveBean(PropagatingReceiverTracingObservationHandler.class); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
void shouldNotSupplyBeansIfTracingIsDisabled() { |
|
|
|
|
this.contextRunner |
|
|
|
|
.withUserConfiguration(TracerConfiguration.class, HttpClientHandlerConfiguration.class, |
|
|
|
|
HttpServerHandlerConfiguration.class) |
|
|
|
|
this.contextRunner.withUserConfiguration(TracerConfiguration.class, PropagatorConfiguration.class) |
|
|
|
|
.withPropertyValues("management.tracing.enabled=false").run((context) -> { |
|
|
|
|
assertThat(context).doesNotHaveBean(DefaultTracingObservationHandler.class); |
|
|
|
|
assertThat(context).doesNotHaveBean(HttpServerTracingObservationHandler.class); |
|
|
|
|
assertThat(context).doesNotHaveBean(HttpClientTracingObservationHandler.class); |
|
|
|
|
assertThat(context).doesNotHaveBean(PropagatingReceiverTracingObservationHandler.class); |
|
|
|
|
assertThat(context).doesNotHaveBean(PropagatingSenderTracingObservationHandler.class); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -139,21 +130,11 @@ class MicrometerTracingAutoConfigurationTests {
@@ -139,21 +130,11 @@ class MicrometerTracingAutoConfigurationTests {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Configuration(proxyBeanMethods = false) |
|
|
|
|
private static class HttpClientHandlerConfiguration { |
|
|
|
|
|
|
|
|
|
@Bean |
|
|
|
|
HttpClientHandler httpClientHandler() { |
|
|
|
|
return mock(HttpClientHandler.class); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Configuration(proxyBeanMethods = false) |
|
|
|
|
private static class HttpServerHandlerConfiguration { |
|
|
|
|
private static class PropagatorConfiguration { |
|
|
|
|
|
|
|
|
|
@Bean |
|
|
|
|
HttpServerHandler httpServerHandler() { |
|
|
|
|
return mock(HttpServerHandler.class); |
|
|
|
|
Propagator propagator() { |
|
|
|
|
return mock(Propagator.class); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
@ -167,13 +148,13 @@ class MicrometerTracingAutoConfigurationTests {
@@ -167,13 +148,13 @@ class MicrometerTracingAutoConfigurationTests {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Bean |
|
|
|
|
HttpServerTracingObservationHandler customHttpServerTracingObservationHandler() { |
|
|
|
|
return mock(HttpServerTracingObservationHandler.class); |
|
|
|
|
PropagatingReceiverTracingObservationHandler<?> customPropagatingReceiverTracingObservationHandler() { |
|
|
|
|
return mock(PropagatingReceiverTracingObservationHandler.class); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Bean |
|
|
|
|
HttpClientTracingObservationHandler customHttpClientTracingObservationHandler() { |
|
|
|
|
return mock(HttpClientTracingObservationHandler.class); |
|
|
|
|
PropagatingSenderTracingObservationHandler<?> customPropagatingSenderTracingObservationHandler() { |
|
|
|
|
return mock(PropagatingSenderTracingObservationHandler.class); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|