Improve JVM metrics

This commit adds GC and thread jvm metrics to the existing memory
metrics. All three are now managed by a unique
management.metrics.binders.jvm.enabled property.

Closes gh-11425
pull/11403/merge
Stephane Nicoll 7 years ago
parent c5802c2950
commit 81af02fde7

@ -17,7 +17,9 @@
package org.springframework.boot.actuate.autoconfigure.metrics;
import io.micrometer.core.instrument.binder.MeterBinder;
import io.micrometer.core.instrument.binder.jvm.JvmGcMetrics;
import io.micrometer.core.instrument.binder.jvm.JvmMemoryMetrics;
import io.micrometer.core.instrument.binder.jvm.JvmThreadMetrics;
import io.micrometer.core.instrument.binder.logging.LogbackMetrics;
import io.micrometer.core.instrument.binder.system.ProcessorMetrics;
import io.micrometer.core.instrument.binder.system.UptimeMetrics;
@ -37,12 +39,26 @@ import org.springframework.context.annotation.Configuration;
class MeterBindersConfiguration {
@Bean
@ConditionalOnProperty(value = "management.metrics.binders.jvmmemory.enabled", matchIfMissing = true)
@ConditionalOnProperty(value = "spring.metrics.binders.jvm.enabled", matchIfMissing = true)
@ConditionalOnMissingBean(JvmGcMetrics.class)
public JvmGcMetrics jvmGcMetrics() {
return new JvmGcMetrics();
}
@Bean
@ConditionalOnProperty(value = "management.metrics.binders.jvm.enabled", matchIfMissing = true)
@ConditionalOnMissingBean(JvmMemoryMetrics.class)
public JvmMemoryMetrics jvmMemoryMetrics() {
return new JvmMemoryMetrics();
}
@Bean
@ConditionalOnProperty(value = "spring.metrics.binders.jvm.enabled", matchIfMissing = true)
@ConditionalOnMissingBean(JvmThreadMetrics.class)
public JvmThreadMetrics jvmThreadMetrics() {
return new JvmThreadMetrics();
}
@Bean
@ConditionalOnMissingBean(LogbackMetrics.class)
@ConditionalOnProperty(value = "management.metrics.binders.logback.enabled", matchIfMissing = true)

@ -192,9 +192,9 @@
"defaultValue": true
},
{
"name": "management.metrics.binders.jvmmemory.enabled",
"name": "management.metrics.binders.jvm.enabled",
"type": "java.lang.Boolean",
"description": "Whether to enable JVM memory metrics.",
"description": "Whether to enable JVM metrics.",
"defaultValue": true
},
{

@ -1248,7 +1248,7 @@ content into your application. Rather, pick only the properties that you need.
management.jolokia.path=/jolokia # Path at which Jolokia is available.
# METRICS
management.metrics.binders.jvmmemory.enabled=true # Whether to enable JVM memory metrics.
management.metrics.binders.jvm.enabled=true # Whether to enable JVM metrics.
management.metrics.binders.logback.enabled=true # Whether to enable Logback metrics.
management.metrics.binders.processor.enabled=true # Whether to enable processor metrics.
management.metrics.binders.uptime.enabled=true # Whether to enable uptime metrics.

Loading…
Cancel
Save