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.test.context.runner.ApplicationContextRunner;
|
||||
|
||||
/**
|
||||
* Integration tests for {@link MeterRegistryConfigurer}.
|
||||
*
|
||||
* @author Jon Schneider
|
||||
*/
|
||||
public class MeterRegistryConfigurerIntegrationTests {
|
||||
|
||||
private ApplicationContextRunner contextRunner = new ApplicationContextRunner()
|
||||
.with(MetricsRun.limitedTo(AtlasMetricsExportAutoConfiguration.class,
|
||||
PrometheusMetricsExportAutoConfiguration.class));
|
||||
|
||||
@Test
|
||||
public void binderMetricsAreSearchableFromTheComposite() {
|
||||
this.contextRunner
|
||||
.run((context) -> {
|
||||
CompositeMeterRegistry composite = context.getBean(CompositeMeterRegistry.class);
|
||||
composite.get("jvm.memory.used").gauge();
|
||||
|
||||
for (MeterRegistry registry : context.getBeansOfType(MeterRegistry.class).values()) {
|
||||
registry.get("jvm.memory.used").gauge();
|
||||
}
|
||||
});
|
||||
this.contextRunner.run((context) -> {
|
||||
CompositeMeterRegistry composite = context
|
||||
.getBean(CompositeMeterRegistry.class);
|
||||
composite.get("jvm.memory.used").gauge();
|
||||
context.getBeansOfType(MeterRegistry.class)
|
||||
.forEach((name, registry) -> registry.get("jvm.memory.used").gauge());
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -67,12 +67,12 @@ public class MeterRegistryCustomizerTests {
|
|||
this.contextRunner
|
||||
.withUserConfiguration(MeterRegistryCustomizerConfiguration.class)
|
||||
.run((context) -> {
|
||||
MeterRegistry prometheus = context.getBean(PrometheusMeterRegistry.class);
|
||||
MeterRegistry prometheus = context
|
||||
.getBean(PrometheusMeterRegistry.class);
|
||||
prometheus.get("jvm.memory.used").tags("job", "myjob").gauge();
|
||||
|
||||
MeterRegistry atlas = context.getBean(AtlasMeterRegistry.class);
|
||||
assertThat(atlas.find("jvm.memory.used").tags("job", "myjob")
|
||||
.gauge()).isNull();
|
||||
assertThat(atlas.find("jvm.memory.used").tags("job", "myjob").gauge())
|
||||
.isNull();
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue