Polish "Apply MeterRegistryCustomizer to composites"
Closes gh-12762
This commit is contained in:
parent
1fce462944
commit
ce9ca6ae70
|
@ -25,21 +25,26 @@ import org.springframework.boot.actuate.autoconfigure.metrics.export.prometheus.
|
||||||
import org.springframework.boot.actuate.autoconfigure.metrics.test.MetricsRun;
|
import org.springframework.boot.actuate.autoconfigure.metrics.test.MetricsRun;
|
||||||
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
|
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Integration tests for {@link MeterRegistryConfigurer}.
|
||||||
|
*
|
||||||
|
* @author Jon Schneider
|
||||||
|
*/
|
||||||
public class MeterRegistryConfigurerIntegrationTests {
|
public class MeterRegistryConfigurerIntegrationTests {
|
||||||
|
|
||||||
private ApplicationContextRunner contextRunner = new ApplicationContextRunner()
|
private ApplicationContextRunner contextRunner = new ApplicationContextRunner()
|
||||||
.with(MetricsRun.limitedTo(AtlasMetricsExportAutoConfiguration.class,
|
.with(MetricsRun.limitedTo(AtlasMetricsExportAutoConfiguration.class,
|
||||||
PrometheusMetricsExportAutoConfiguration.class));
|
PrometheusMetricsExportAutoConfiguration.class));
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void binderMetricsAreSearchableFromTheComposite() {
|
public void binderMetricsAreSearchableFromTheComposite() {
|
||||||
this.contextRunner
|
this.contextRunner.run((context) -> {
|
||||||
.run((context) -> {
|
CompositeMeterRegistry composite = context
|
||||||
CompositeMeterRegistry composite = context.getBean(CompositeMeterRegistry.class);
|
.getBean(CompositeMeterRegistry.class);
|
||||||
composite.get("jvm.memory.used").gauge();
|
composite.get("jvm.memory.used").gauge();
|
||||||
|
context.getBeansOfType(MeterRegistry.class)
|
||||||
for (MeterRegistry registry : context.getBeansOfType(MeterRegistry.class).values()) {
|
.forEach((name, registry) -> registry.get("jvm.memory.used").gauge());
|
||||||
registry.get("jvm.memory.used").gauge();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,12 +67,12 @@ public class MeterRegistryCustomizerTests {
|
||||||
this.contextRunner
|
this.contextRunner
|
||||||
.withUserConfiguration(MeterRegistryCustomizerConfiguration.class)
|
.withUserConfiguration(MeterRegistryCustomizerConfiguration.class)
|
||||||
.run((context) -> {
|
.run((context) -> {
|
||||||
MeterRegistry prometheus = context.getBean(PrometheusMeterRegistry.class);
|
MeterRegistry prometheus = context
|
||||||
|
.getBean(PrometheusMeterRegistry.class);
|
||||||
prometheus.get("jvm.memory.used").tags("job", "myjob").gauge();
|
prometheus.get("jvm.memory.used").tags("job", "myjob").gauge();
|
||||||
|
|
||||||
MeterRegistry atlas = context.getBean(AtlasMeterRegistry.class);
|
MeterRegistry atlas = context.getBean(AtlasMeterRegistry.class);
|
||||||
assertThat(atlas.find("jvm.memory.used").tags("job", "myjob")
|
assertThat(atlas.find("jvm.memory.used").tags("job", "myjob").gauge())
|
||||||
.gauge()).isNull();
|
.isNull();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue