mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-08-29 03:06:45 +08:00
Polish "Ensure that MeterRegistry bean is defined before SI looks for it"
See gh-24095
This commit is contained in:
parent
7d712aaa2d
commit
08b9d1da57
@ -33,11 +33,10 @@ import org.springframework.context.annotation.Configuration;
|
||||
* for it.
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
* @since 2.3.6
|
||||
*/
|
||||
@AutoConfigureAfter({ MetricsAutoConfiguration.class, CompositeMeterRegistryAutoConfiguration.class })
|
||||
@AutoConfigureBefore(IntegrationAutoConfiguration.class)
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
public class IntegrationMetricsAutoConfiguration {
|
||||
class IntegrationMetricsAutoConfiguration {
|
||||
|
||||
}
|
||||
|
@ -65,8 +65,8 @@ org.springframework.boot.actuate.autoconfigure.metrics.export.signalfx.SignalFxM
|
||||
org.springframework.boot.actuate.autoconfigure.metrics.export.simple.SimpleMetricsExportAutoConfiguration,\
|
||||
org.springframework.boot.actuate.autoconfigure.metrics.export.statsd.StatsdMetricsExportAutoConfiguration,\
|
||||
org.springframework.boot.actuate.autoconfigure.metrics.export.wavefront.WavefrontMetricsExportAutoConfiguration,\
|
||||
org.springframework.boot.actuate.autoconfigure.metrics.jdbc.DataSourcePoolMetricsAutoConfiguration,\
|
||||
org.springframework.boot.actuate.autoconfigure.metrics.integration.IntegrationMetricsAutoConfiguration,\
|
||||
org.springframework.boot.actuate.autoconfigure.metrics.jdbc.DataSourcePoolMetricsAutoConfiguration,\
|
||||
org.springframework.boot.actuate.autoconfigure.metrics.jersey.JerseyServerMetricsAutoConfiguration,\
|
||||
org.springframework.boot.actuate.autoconfigure.metrics.orm.jpa.HibernateMetricsAutoConfiguration,\
|
||||
org.springframework.boot.actuate.autoconfigure.metrics.web.client.HttpClientMetricsAutoConfiguration,\
|
||||
|
@ -16,7 +16,8 @@
|
||||
|
||||
package org.springframework.boot.actuate.autoconfigure.metrics.integration;
|
||||
|
||||
|
||||
import io.micrometer.core.instrument.Gauge;
|
||||
import io.micrometer.core.instrument.MeterRegistry;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.boot.actuate.autoconfigure.integration.IntegrationGraphEndpointAutoConfiguration;
|
||||
@ -26,35 +27,25 @@ import org.springframework.boot.autoconfigure.AutoConfigurations;
|
||||
import org.springframework.boot.autoconfigure.integration.IntegrationAutoConfiguration;
|
||||
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
|
||||
|
||||
import io.micrometer.core.instrument.Gauge;
|
||||
import io.micrometer.core.instrument.MeterRegistry;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Tests for {@link RabbitMetricsAutoConfiguration}.
|
||||
*
|
||||
* @author Artem Bilan
|
||||
* @since 2.3.6
|
||||
*/
|
||||
class IntegrationMetricsAutoConfigurationTests {
|
||||
|
||||
private final ApplicationContextRunner contextRunner =
|
||||
new ApplicationContextRunner()
|
||||
.withConfiguration(AutoConfigurations.of(
|
||||
IntegrationAutoConfiguration.class,
|
||||
IntegrationGraphEndpointAutoConfiguration.class))
|
||||
.with(MetricsRun.simple())
|
||||
.withPropertyValues("management.metrics.tags.someTag=someValue");
|
||||
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
|
||||
.withConfiguration(AutoConfigurations.of(IntegrationAutoConfiguration.class,
|
||||
IntegrationGraphEndpointAutoConfiguration.class, IntegrationMetricsAutoConfiguration.class))
|
||||
.with(MetricsRun.simple()).withPropertyValues("management.metrics.tags.someTag=someValue");
|
||||
|
||||
@Test
|
||||
void integrationMetersAreInstrumented() {
|
||||
this.contextRunner.run((context) -> {
|
||||
MeterRegistry registry = context.getBean(MeterRegistry.class);
|
||||
Gauge gauge =
|
||||
registry.get("spring.integration.channels")
|
||||
.tag("someTag", "someValue")
|
||||
.gauge();
|
||||
Gauge gauge = registry.get("spring.integration.channels").tag("someTag", "someValue").gauge();
|
||||
assertThat(gauge).isNotNull().extracting(Gauge::value).isEqualTo(2.0);
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user