com.codahale.metrics.jvm.ClassLoadingGaugeSet Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of metrics-jvm Show documentation
Show all versions of metrics-jvm Show documentation
A set of classes which allow you to monitor critical aspects of your Java Virtual Machine
using Metrics.
The newest version!
package com.codahale.metrics.jvm;
import com.codahale.metrics.Gauge;
import com.codahale.metrics.Metric;
import com.codahale.metrics.MetricSet;
import java.lang.management.ClassLoadingMXBean;
import java.lang.management.ManagementFactory;
import java.util.HashMap;
import java.util.Map;
/**
* A set of gauges for JVM classloader usage.
*/
public class ClassLoadingGaugeSet implements MetricSet {
private final ClassLoadingMXBean mxBean;
public ClassLoadingGaugeSet() {
this(ManagementFactory.getClassLoadingMXBean());
}
public ClassLoadingGaugeSet(ClassLoadingMXBean mxBean) {
this.mxBean = mxBean;
}
@Override
public Map getMetrics() {
final Map gauges = new HashMap<>();
gauges.put("loaded", (Gauge) mxBean::getTotalLoadedClassCount);
gauges.put("unloaded", (Gauge) mxBean::getUnloadedClassCount);
return gauges;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy