use of com.codahale.metrics.JmxAttributeGauge in project metrics by dropwizard.
the class JCacheGaugeSet method getMetrics.
@Override
public Map<String, Metric> getMetrics() {
Set<ObjectInstance> cacheBeans = getCacheBeans();
List<String> availableStatsNames = retrieveStatsNames();
Map<String, Metric> gauges = new HashMap<String, Metric>(cacheBeans.size() * availableStatsNames.size());
for (ObjectInstance cacheBean : cacheBeans) {
ObjectName objectName = cacheBean.getObjectName();
String cacheName = objectName.getKeyProperty("Cache");
for (String statsName : availableStatsNames) {
JmxAttributeGauge jmxAttributeGauge = new JmxAttributeGauge(objectName, statsName);
gauges.put(name(cacheName, toSpinalCase(statsName)), jmxAttributeGauge);
}
}
return Collections.unmodifiableMap(gauges);
}
use of com.codahale.metrics.JmxAttributeGauge in project metrics by dropwizard.
the class BufferPoolMetricSet method getMetrics.
@Override
public Map<String, Metric> getMetrics() {
final Map<String, Metric> gauges = new HashMap<String, Metric>();
for (String pool : POOLS) {
for (int i = 0; i < ATTRIBUTES.length; i++) {
final String attribute = ATTRIBUTES[i];
final String name = NAMES[i];
try {
final ObjectName on = new ObjectName("java.nio:type=BufferPool,name=" + pool);
mBeanServer.getMBeanInfo(on);
gauges.put(name(pool, name), new JmxAttributeGauge(mBeanServer, on, attribute));
} catch (JMException ignored) {
LOGGER.debug("Unable to load buffer pool MBeans, possibly running on Java 6");
}
}
}
return Collections.unmodifiableMap(gauges);
}
Aggregations