mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-08-29 03:06:45 +08:00
Build against Micrometer 1.10.0-M5 and Tracing 1.0.0-M8 snapshots
See gh-32048 Co-authored-by: Marcin Grzejszczak <mgrzejszczak@vmware.com>
This commit is contained in:
parent
d1810941e8
commit
13a2ea9194
@ -17,26 +17,27 @@
|
||||
package org.springframework.boot.actuate.autoconfigure.observation;
|
||||
|
||||
import io.micrometer.core.instrument.MeterRegistry;
|
||||
import io.micrometer.core.instrument.observation.TimerObservationHandler;
|
||||
import io.micrometer.core.instrument.observation.DefaultMeterObservationHandler;
|
||||
import io.micrometer.observation.ObservationRegistry;
|
||||
|
||||
/**
|
||||
* Registers the {@link TimerObservationHandler} with an {@link ObservationRegistry}.
|
||||
* Registers the {@link DefaultMeterObservationHandler} with an
|
||||
* {@link ObservationRegistry}.
|
||||
*
|
||||
* @author Moritz Halbritter
|
||||
*/
|
||||
class TimerObservationHandlerObservationRegistryCustomizer
|
||||
class DefaultMeterObservationHandlerObservationRegistryCustomizer
|
||||
implements ObservationRegistryCustomizer<ObservationRegistry> {
|
||||
|
||||
private final MeterRegistry meterRegistry;
|
||||
|
||||
TimerObservationHandlerObservationRegistryCustomizer(MeterRegistry meterRegistry) {
|
||||
DefaultMeterObservationHandlerObservationRegistryCustomizer(MeterRegistry meterRegistry) {
|
||||
this.meterRegistry = meterRegistry;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void customize(ObservationRegistry registry) {
|
||||
registry.observationConfig().observationHandler(new TimerObservationHandler(this.meterRegistry));
|
||||
registry.observationConfig().observationHandler(new DefaultMeterObservationHandler(this.meterRegistry));
|
||||
}
|
||||
|
||||
}
|
@ -17,7 +17,7 @@
|
||||
package org.springframework.boot.actuate.autoconfigure.observation;
|
||||
|
||||
import io.micrometer.core.instrument.MeterRegistry;
|
||||
import io.micrometer.observation.Observation.GlobalKeyValuesProvider;
|
||||
import io.micrometer.observation.Observation.GlobalObservationConvention;
|
||||
import io.micrometer.observation.ObservationHandler;
|
||||
import io.micrometer.observation.ObservationPredicate;
|
||||
import io.micrometer.observation.ObservationRegistry;
|
||||
@ -48,11 +48,11 @@ public class ObservationAutoConfiguration {
|
||||
static ObservationRegistryPostProcessor observationRegistryPostProcessor(
|
||||
ObjectProvider<ObservationRegistryCustomizer<?>> observationRegistryCustomizers,
|
||||
ObjectProvider<ObservationPredicate> observationPredicates,
|
||||
ObjectProvider<GlobalKeyValuesProvider<?>> keyValuesProviders,
|
||||
ObjectProvider<GlobalObservationConvention<?>> observationConventions,
|
||||
ObjectProvider<ObservationHandler<?>> observationHandlers,
|
||||
ObjectProvider<ObservationHandlerGrouping> observationHandlerGrouping) {
|
||||
return new ObservationRegistryPostProcessor(observationRegistryCustomizers, observationPredicates,
|
||||
keyValuesProviders, observationHandlers, observationHandlerGrouping);
|
||||
observationConventions, observationHandlers, observationHandlerGrouping);
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ -66,9 +66,9 @@ public class ObservationAutoConfiguration {
|
||||
static class MetricsConfiguration {
|
||||
|
||||
@Bean
|
||||
TimerObservationHandlerObservationRegistryCustomizer enableTimerObservationHandler(
|
||||
DefaultMeterObservationHandlerObservationRegistryCustomizer enableDefaultMeterObservationHandler(
|
||||
MeterRegistry meterRegistry) {
|
||||
return new TimerObservationHandlerObservationRegistryCustomizer(meterRegistry);
|
||||
return new DefaultMeterObservationHandlerObservationRegistryCustomizer(meterRegistry);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ package org.springframework.boot.actuate.autoconfigure.observation;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.micrometer.observation.Observation.GlobalKeyValuesProvider;
|
||||
import io.micrometer.observation.Observation.GlobalObservationConvention;
|
||||
import io.micrometer.observation.ObservationHandler;
|
||||
import io.micrometer.observation.ObservationPredicate;
|
||||
import io.micrometer.observation.ObservationRegistry;
|
||||
@ -29,10 +29,10 @@ import org.springframework.boot.util.LambdaSafe;
|
||||
/**
|
||||
* Configurer to apply {@link ObservationRegistryCustomizer customizers} to
|
||||
* {@link ObservationRegistry observation registries}. Installs
|
||||
* {@link ObservationPredicate observation predicates} and {@link GlobalKeyValuesProvider
|
||||
* global key values providers} into the {@link ObservationRegistry}. Also uses a
|
||||
* {@link ObservationHandlerGrouping} to group handlers, which are then added to the
|
||||
* {@link ObservationRegistry}.
|
||||
* {@link ObservationPredicate observation predicates} and
|
||||
* {@link GlobalObservationConvention global observation conventions} into the
|
||||
* {@link ObservationRegistry}. Also uses a {@link ObservationHandlerGrouping} to group
|
||||
* handlers, which are then added to the {@link ObservationRegistry}.
|
||||
*
|
||||
* @author Moritz Halbritter
|
||||
*/
|
||||
@ -42,7 +42,7 @@ class ObservationRegistryConfigurer {
|
||||
|
||||
private final ObjectProvider<ObservationPredicate> observationPredicates;
|
||||
|
||||
private final ObjectProvider<GlobalKeyValuesProvider<?>> keyValuesProviders;
|
||||
private final ObjectProvider<GlobalObservationConvention<?>> observationConventions;
|
||||
|
||||
private final ObjectProvider<ObservationHandler<?>> observationHandlers;
|
||||
|
||||
@ -50,19 +50,19 @@ class ObservationRegistryConfigurer {
|
||||
|
||||
ObservationRegistryConfigurer(ObjectProvider<ObservationRegistryCustomizer<?>> customizers,
|
||||
ObjectProvider<ObservationPredicate> observationPredicates,
|
||||
ObjectProvider<GlobalKeyValuesProvider<?>> keyValuesProviders,
|
||||
ObjectProvider<GlobalObservationConvention<?>> observationConventions,
|
||||
ObjectProvider<ObservationHandler<?>> observationHandlers,
|
||||
ObjectProvider<ObservationHandlerGrouping> observationHandlerGrouping) {
|
||||
this.customizers = customizers;
|
||||
this.observationPredicates = observationPredicates;
|
||||
this.keyValuesProviders = keyValuesProviders;
|
||||
this.observationConventions = observationConventions;
|
||||
this.observationHandlers = observationHandlers;
|
||||
this.observationHandlerGrouping = observationHandlerGrouping;
|
||||
}
|
||||
|
||||
void configure(ObservationRegistry registry) {
|
||||
registerObservationPredicates(registry);
|
||||
registerGlobalKeyValuesProviders(registry);
|
||||
registerGlobalObservationConventions(registry);
|
||||
registerHandlers(registry);
|
||||
customize(registry);
|
||||
}
|
||||
@ -77,9 +77,9 @@ class ObservationRegistryConfigurer {
|
||||
(observationPredicate) -> registry.observationConfig().observationPredicate(observationPredicate));
|
||||
}
|
||||
|
||||
private void registerGlobalKeyValuesProviders(ObservationRegistry registry) {
|
||||
this.keyValuesProviders.orderedStream()
|
||||
.forEach((keyValuesProvider) -> registry.observationConfig().keyValuesProvider(keyValuesProvider));
|
||||
private void registerGlobalObservationConventions(ObservationRegistry registry) {
|
||||
this.observationConventions.orderedStream()
|
||||
.forEach((convention) -> registry.observationConfig().observationConvention(convention));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.boot.actuate.autoconfigure.observation;
|
||||
|
||||
import io.micrometer.observation.Observation.GlobalKeyValuesProvider;
|
||||
import io.micrometer.observation.Observation.GlobalObservationConvention;
|
||||
import io.micrometer.observation.ObservationHandler;
|
||||
import io.micrometer.observation.ObservationPredicate;
|
||||
import io.micrometer.observation.ObservationRegistry;
|
||||
@ -38,7 +38,7 @@ class ObservationRegistryPostProcessor implements BeanPostProcessor {
|
||||
|
||||
private final ObjectProvider<ObservationPredicate> observationPredicates;
|
||||
|
||||
private final ObjectProvider<GlobalKeyValuesProvider<?>> keyValuesProviders;
|
||||
private final ObjectProvider<GlobalObservationConvention<?>> observationConventions;
|
||||
|
||||
private final ObjectProvider<ObservationHandler<?>> observationHandlers;
|
||||
|
||||
@ -48,12 +48,12 @@ class ObservationRegistryPostProcessor implements BeanPostProcessor {
|
||||
|
||||
ObservationRegistryPostProcessor(ObjectProvider<ObservationRegistryCustomizer<?>> observationRegistryCustomizers,
|
||||
ObjectProvider<ObservationPredicate> observationPredicates,
|
||||
ObjectProvider<GlobalKeyValuesProvider<?>> keyValuesProviders,
|
||||
ObjectProvider<GlobalObservationConvention<?>> observationConventions,
|
||||
ObjectProvider<ObservationHandler<?>> observationHandlers,
|
||||
ObjectProvider<ObservationHandlerGrouping> observationHandlerGrouping) {
|
||||
this.observationRegistryCustomizers = observationRegistryCustomizers;
|
||||
this.observationPredicates = observationPredicates;
|
||||
this.keyValuesProviders = keyValuesProviders;
|
||||
this.observationConventions = observationConventions;
|
||||
this.observationHandlers = observationHandlers;
|
||||
this.observationHandlerGrouping = observationHandlerGrouping;
|
||||
}
|
||||
@ -69,7 +69,7 @@ class ObservationRegistryPostProcessor implements BeanPostProcessor {
|
||||
private ObservationRegistryConfigurer getConfigurer() {
|
||||
if (this.configurer == null) {
|
||||
this.configurer = new ObservationRegistryConfigurer(this.observationRegistryCustomizers,
|
||||
this.observationPredicates, this.keyValuesProviders, this.observationHandlers,
|
||||
this.observationPredicates, this.observationConventions, this.observationHandlers,
|
||||
this.observationHandlerGrouping);
|
||||
}
|
||||
return this.configurer;
|
||||
|
@ -18,10 +18,9 @@ package org.springframework.boot.actuate.autoconfigure.tracing;
|
||||
|
||||
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.http.HttpClientHandler;
|
||||
import io.micrometer.tracing.http.HttpServerHandler;
|
||||
import io.micrometer.tracing.handler.PropagatingReceiverTracingObservationHandler;
|
||||
import io.micrometer.tracing.handler.PropagatingSenderTracingObservationHandler;
|
||||
import io.micrometer.tracing.propagation.Propagator;
|
||||
|
||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
@ -50,40 +49,39 @@ public class MicrometerTracingAutoConfiguration {
|
||||
|
||||
/**
|
||||
* {@code @Order} value of
|
||||
* {@link #httpServerTracingObservationHandler(Tracer, HttpServerHandler)}.
|
||||
* {@link #propagatingReceiverTracingObservationHandler(Tracer, Propagator)}.
|
||||
*/
|
||||
public static final int HTTP_SERVER_TRACING_OBSERVATION_HANDLER_ORDER = 1000;
|
||||
public static final int RECEIVER_TRACING_OBSERVATION_HANDLER_ORDER = 1000;
|
||||
|
||||
/**
|
||||
* {@code @Order} value of
|
||||
* {@link #httpClientTracingObservationHandler(Tracer, HttpClientHandler)}.
|
||||
* {@link #propagatingSenderTracingObservationHandler(Tracer, Propagator)}.
|
||||
*/
|
||||
public static final int HTTP_CLIENT_TRACING_OBSERVATION_HANDLER_ORDER = 2000;
|
||||
public static final int SENDER_TRACING_OBSERVATION_HANDLER_ORDER = 2000;
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
@ConditionalOnBean(Tracer.class)
|
||||
@Order(DEFAULT_TRACING_OBSERVATION_HANDLER_ORDER)
|
||||
public DefaultTracingObservationHandler defaultTracingObservationHandler(Tracer tracer) {
|
||||
return new DefaultTracingObservationHandler(tracer);
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
@ConditionalOnBean({ Tracer.class, HttpServerHandler.class })
|
||||
@Order(HTTP_SERVER_TRACING_OBSERVATION_HANDLER_ORDER)
|
||||
public HttpServerTracingObservationHandler httpServerTracingObservationHandler(Tracer tracer,
|
||||
HttpServerHandler httpServerHandler) {
|
||||
return new HttpServerTracingObservationHandler(tracer, httpServerHandler);
|
||||
@ConditionalOnBean({ Tracer.class, Propagator.class })
|
||||
@Order(SENDER_TRACING_OBSERVATION_HANDLER_ORDER)
|
||||
public PropagatingSenderTracingObservationHandler<?> propagatingSenderTracingObservationHandler(Tracer tracer,
|
||||
Propagator propagator) {
|
||||
return new PropagatingSenderTracingObservationHandler<>(tracer, propagator);
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
@ConditionalOnBean({ Tracer.class, HttpClientHandler.class })
|
||||
@Order(HTTP_CLIENT_TRACING_OBSERVATION_HANDLER_ORDER)
|
||||
public HttpClientTracingObservationHandler httpClientTracingObservationHandler(Tracer tracer,
|
||||
HttpClientHandler httpClientHandler) {
|
||||
return new HttpClientTracingObservationHandler(tracer, httpClientHandler);
|
||||
@ConditionalOnBean({ Tracer.class, Propagator.class })
|
||||
@Order(RECEIVER_TRACING_OBSERVATION_HANDLER_ORDER)
|
||||
public PropagatingReceiverTracingObservationHandler<?> propagatingReceiverTracingObservationHandler(Tracer tracer,
|
||||
Propagator propagator) {
|
||||
return new PropagatingReceiverTracingObservationHandler<>(tracer, propagator);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -25,16 +25,16 @@ import org.junit.jupiter.api.Test;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Tests for {@link TimerObservationHandlerObservationRegistryCustomizer}.
|
||||
* Tests for {@link DefaultMeterObservationHandlerObservationRegistryCustomizer}.
|
||||
*
|
||||
* @author Moritz Halbritter
|
||||
*/
|
||||
class TimerObservationHandlerObservationRegistryCustomizerTests {
|
||||
class DefaultMeterObservationHandlerObservationRegistryCustomizerTests {
|
||||
|
||||
@Test
|
||||
void customizeInstallsTimerObservationHandler() {
|
||||
void customizeInstallsDefaultMeterObservationHandler() {
|
||||
MeterRegistry meterRegistry = new SimpleMeterRegistry();
|
||||
TimerObservationHandlerObservationRegistryCustomizer sut = new TimerObservationHandlerObservationRegistryCustomizer(
|
||||
DefaultMeterObservationHandlerObservationRegistryCustomizer sut = new DefaultMeterObservationHandlerObservationRegistryCustomizer(
|
||||
meterRegistry);
|
||||
ObservationRegistry observationRegistry = ObservationRegistry.create();
|
||||
sut.customize(observationRegistry);
|
@ -26,7 +26,7 @@ import io.micrometer.core.instrument.observation.MeterObservationHandler;
|
||||
import io.micrometer.core.instrument.search.MeterNotFoundException;
|
||||
import io.micrometer.observation.Observation;
|
||||
import io.micrometer.observation.Observation.Context;
|
||||
import io.micrometer.observation.Observation.GlobalKeyValuesProvider;
|
||||
import io.micrometer.observation.Observation.GlobalObservationConvention;
|
||||
import io.micrometer.observation.ObservationHandler;
|
||||
import io.micrometer.observation.ObservationHandler.AllMatchingCompositeObservationHandler;
|
||||
import io.micrometer.observation.ObservationHandler.FirstMatchingCompositeObservationHandler;
|
||||
@ -65,22 +65,22 @@ class ObservationAutoConfigurationTests {
|
||||
.with(MetricsRun.simple()).withConfiguration(AutoConfigurations.of(ObservationAutoConfiguration.class));
|
||||
|
||||
@Test
|
||||
void autoConfiguresTimerObservationHandler() {
|
||||
void autoConfiguresDefaultMeterObservationHandler() {
|
||||
this.contextRunner.run((context) -> {
|
||||
ObservationRegistry observationRegistry = context.getBean(ObservationRegistry.class);
|
||||
Observation.start("test-observation", observationRegistry).stop();
|
||||
// When a TimerObservationHandler is registered, every stopped Observation
|
||||
// leads to a timer
|
||||
// When a DefaultMeterObservationHandler is registered, every stopped
|
||||
// Observation leads to a timer
|
||||
MeterRegistry meterRegistry = context.getBean(MeterRegistry.class);
|
||||
assertThat(meterRegistry.get("test-observation").timer().count()).isEqualTo(1);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void allowsTimerObservationHandlerToBeDisabled() {
|
||||
void allowsDefaultMeterObservationHandlerToBeDisabled() {
|
||||
this.contextRunner.withClassLoader(new FilteredClassLoader(MeterRegistry.class))
|
||||
.run((context) -> assertThat(context)
|
||||
.doesNotHaveBean(TimerObservationHandlerObservationRegistryCustomizer.class));
|
||||
.doesNotHaveBean(DefaultMeterObservationHandlerObservationRegistryCustomizer.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -177,8 +177,8 @@ class ObservationAutoConfigurationTests {
|
||||
static class GlobalKeyValuesProviders {
|
||||
|
||||
@Bean
|
||||
Observation.GlobalKeyValuesProvider<?> customKeyValuesProvider() {
|
||||
return new GlobalKeyValuesProvider<>() {
|
||||
GlobalObservationConvention<?> customConvention() {
|
||||
return new GlobalObservationConvention<>() {
|
||||
@Override
|
||||
public boolean supportsContext(Context context) {
|
||||
return true;
|
||||
|
@ -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 {
|
||||
|
||||
@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 {
|
||||
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 {
|
||||
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);
|
||||
});
|
||||
this.contextRunner.withUserConfiguration(PropagatorConfiguration.class).run((context) -> {
|
||||
assertThat(context).doesNotHaveBean(DefaultTracingObservationHandler.class);
|
||||
assertThat(context).doesNotHaveBean(PropagatingReceiverTracingObservationHandler.class);
|
||||
assertThat(context).doesNotHaveBean(PropagatingSenderTracingObservationHandler.class);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldNotSupplyBeansIfHttpClientHandlerIsMissing() {
|
||||
this.contextRunner.withUserConfiguration(TracerConfiguration.class, HttpServerHandlerConfiguration.class)
|
||||
.run((context) -> assertThat(context).doesNotHaveBean(HttpClientTracingObservationHandler.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 {
|
||||
}
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
private static class HttpClientHandlerConfiguration {
|
||||
private static class PropagatorConfiguration {
|
||||
|
||||
@Bean
|
||||
HttpClientHandler httpClientHandler() {
|
||||
return mock(HttpClientHandler.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
private static class HttpServerHandlerConfiguration {
|
||||
|
||||
@Bean
|
||||
HttpServerHandler httpServerHandler() {
|
||||
return mock(HttpServerHandler.class);
|
||||
Propagator propagator() {
|
||||
return mock(Propagator.class);
|
||||
}
|
||||
|
||||
}
|
||||
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1012,7 +1012,7 @@ bom {
|
||||
]
|
||||
}
|
||||
}
|
||||
library("Micrometer", "1.10.0-M3") {
|
||||
library("Micrometer", "1.10.0-SNAPSHOT") {
|
||||
group("io.micrometer") {
|
||||
modules = [
|
||||
"micrometer-registry-stackdriver" {
|
||||
@ -1024,7 +1024,7 @@ bom {
|
||||
]
|
||||
}
|
||||
}
|
||||
library("Micrometer Tracing", "1.0.0-M6") {
|
||||
library("Micrometer Tracing", "1.0.0-SNAPSHOT") {
|
||||
group("io.micrometer") {
|
||||
imports = [
|
||||
"micrometer-tracing-bom"
|
||||
|
Loading…
Reference in New Issue
Block a user