|
|
|
@ -16,10 +16,7 @@
|
|
|
|
|
|
|
|
|
|
package org.springframework.boot.actuate.autoconfigure.metrics;
|
|
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
|
|
|
|
|
|
import io.micrometer.core.instrument.binder.jvm.ClassLoaderMetrics;
|
|
|
|
|
import io.micrometer.core.instrument.binder.jvm.DiskSpaceMetrics;
|
|
|
|
|
import io.micrometer.core.instrument.binder.jvm.JvmGcMetrics;
|
|
|
|
|
import io.micrometer.core.instrument.binder.jvm.JvmMemoryMetrics;
|
|
|
|
|
import io.micrometer.core.instrument.binder.jvm.JvmThreadMetrics;
|
|
|
|
@ -40,7 +37,6 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|
|
|
|
*
|
|
|
|
|
* @author Andy Wilkinson
|
|
|
|
|
* @author Stephane Nicoll
|
|
|
|
|
* @author Chris Bono
|
|
|
|
|
*/
|
|
|
|
|
class JvmMetricsAutoConfigurationTests {
|
|
|
|
|
|
|
|
|
@ -76,16 +72,9 @@ class JvmMetricsAutoConfigurationTests {
|
|
|
|
|
assertMetricsBeans().andThen((context) -> assertThat(context).hasBean("customClassLoaderMetrics")));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
void allowsCustomDiskSpaceMetricsToBeUsed() {
|
|
|
|
|
this.contextRunner.withUserConfiguration(CustomDiskSpaceMetricsConfiguration.class)
|
|
|
|
|
.run(assertMetricsBeans().andThen((context) -> assertThat(context).hasBean("customDiskSpaceMetrics")));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private ContextConsumer<AssertableApplicationContext> assertMetricsBeans() {
|
|
|
|
|
return (context) -> assertThat(context).hasSingleBean(JvmGcMetrics.class).hasSingleBean(JvmMemoryMetrics.class)
|
|
|
|
|
.hasSingleBean(JvmThreadMetrics.class).hasSingleBean(ClassLoaderMetrics.class)
|
|
|
|
|
.hasSingleBean(DiskSpaceMetrics.class);
|
|
|
|
|
.hasSingleBean(JvmThreadMetrics.class).hasSingleBean(ClassLoaderMetrics.class);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Configuration(proxyBeanMethods = false)
|
|
|
|
@ -128,14 +117,4 @@ class JvmMetricsAutoConfigurationTests {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Configuration(proxyBeanMethods = false)
|
|
|
|
|
static class CustomDiskSpaceMetricsConfiguration {
|
|
|
|
|
|
|
|
|
|
@Bean
|
|
|
|
|
DiskSpaceMetrics customDiskSpaceMetrics() {
|
|
|
|
|
return new DiskSpaceMetrics(new File(System.getProperty("user.dir")));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|