mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-09-03 04:26:12 +08:00
Merge branch '3.0.x' into 3.1.x
Closes gh-36429
This commit is contained in:
commit
7195d87e6c
@ -90,7 +90,7 @@ public class PrometheusMetricsExportAutoConfiguration {
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
@ConditionalOnMissingBean(ExemplarSampler.class)
|
||||
@ConditionalOnBean(SpanContextSupplier.class)
|
||||
public DefaultExemplarSampler exemplarSampler(SpanContextSupplier spanContextSupplier) {
|
||||
return new DefaultExemplarSampler(spanContextSupplier);
|
||||
|
@ -45,6 +45,7 @@ import org.springframework.context.annotation.Import;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
/**
|
||||
* Tests for {@link PrometheusMetricsExportAutoConfiguration}.
|
||||
@ -125,6 +126,15 @@ class PrometheusMetricsExportAutoConfigurationTests {
|
||||
.hasSingleBean(PrometheusMeterRegistry.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void allowsCustomExemplarSamplerToBeUsed() {
|
||||
this.contextRunner.withUserConfiguration(ExemplarsConfiguration.class)
|
||||
.withBean("customExemplarSampler", ExemplarSampler.class, () -> mock(ExemplarSampler.class))
|
||||
.run((context) -> assertThat(context).hasSingleBean(ExemplarSampler.class)
|
||||
.getBean(ExemplarSampler.class)
|
||||
.isSameAs(context.getBean("customExemplarSampler")));
|
||||
}
|
||||
|
||||
@Test
|
||||
void exemplarSamplerIsNotAutoConfiguredIfSpanContextSupplierIsMissing() {
|
||||
this.contextRunner.withUserConfiguration(BaseConfiguration.class)
|
||||
|
Loading…
Reference in New Issue
Block a user