Auto-configure JVM heap pressure metrics

See gh-27868
pull/27660/head
Vladimir Konkov 3 years ago committed by Stephane Nicoll
parent 2286f58e23
commit ba21c90355

@ -19,6 +19,7 @@ package org.springframework.boot.actuate.autoconfigure.metrics;
import io.micrometer.core.instrument.MeterRegistry;
import io.micrometer.core.instrument.binder.jvm.ClassLoaderMetrics;
import io.micrometer.core.instrument.binder.jvm.JvmGcMetrics;
import io.micrometer.core.instrument.binder.jvm.JvmHeapPressureMetrics;
import io.micrometer.core.instrument.binder.jvm.JvmMemoryMetrics;
import io.micrometer.core.instrument.binder.jvm.JvmThreadMetrics;
@ -48,6 +49,12 @@ public class JvmMetricsAutoConfiguration {
return new JvmGcMetrics();
}
@Bean
@ConditionalOnMissingBean
public JvmHeapPressureMetrics jvmHeapPressureMetrics() {
return new JvmHeapPressureMetrics();
}
@Bean
@ConditionalOnMissingBean
public JvmMemoryMetrics jvmMemoryMetrics() {

@ -18,6 +18,7 @@ package org.springframework.boot.actuate.autoconfigure.metrics;
import io.micrometer.core.instrument.binder.jvm.ClassLoaderMetrics;
import io.micrometer.core.instrument.binder.jvm.JvmGcMetrics;
import io.micrometer.core.instrument.binder.jvm.JvmHeapPressureMetrics;
import io.micrometer.core.instrument.binder.jvm.JvmMemoryMetrics;
import io.micrometer.core.instrument.binder.jvm.JvmThreadMetrics;
import org.junit.jupiter.api.Test;
@ -74,7 +75,8 @@ class JvmMetricsAutoConfigurationTests {
private ContextConsumer<AssertableApplicationContext> assertMetricsBeans() {
return (context) -> assertThat(context).hasSingleBean(JvmGcMetrics.class).hasSingleBean(JvmMemoryMetrics.class)
.hasSingleBean(JvmThreadMetrics.class).hasSingleBean(ClassLoaderMetrics.class);
.hasSingleBean(JvmHeapPressureMetrics.class).hasSingleBean(JvmThreadMetrics.class)
.hasSingleBean(ClassLoaderMetrics.class);
}
@Configuration(proxyBeanMethods = false)

Loading…
Cancel
Save