Source:
public void register(ResourceDMBean resourceDMBean) { MetricRegistry registry = getRegistry(); ObjectName objectName = resourceDMBean.getObjectName(); int metricCounter = 0; if (log.isDebugEnabled()) { log.debugf("Metric registry @%x contains %d metrics. Registering metrics for ObjectName \"%s\" ...", System.identityHashCode(registry), registry.getMetrics().size(), objectName); } MBeanInfo mBeanInfo = resourceDMBean.getMBeanInfo(); MBeanAttributeInfo[] mBeanAttributes = mBeanInfo.getAttributes(); Tag[] tags = ObjectNameMapper.makeTags(objectName); for (MBeanAttributeInfo attr : mBeanAttributes) { if (!attr.isReadable()) { continue; } String attrName = attr.getName(); Supplier valueSupplier; try { valueSupplier = resourceDMBean.getAttributeValueSupplier(attrName); if (valueSupplier == null) { continue; } } catch (AttributeNotFoundException e) { throw new IllegalStateException(e); } Gauge<Number> gaugeMetric = () -> (Number) valueSupplier.get(); String metricName = ObjectNameMapper.makeMetricName(objectName, attrName); Metadata metadata = new MetadataBuilder() .withType(MetricType.GAUGE) .withName(metricName) .withDisplayName(attr.getName()) .withDescription(attr.getDescription()) .build(); if (log.isDebugEnabled()) { log.debugf("Registering metric %s with tags %s", metricName, Arrays.toString(tags)); metricCounter++; } registry.register(metadata, gaugeMetric, tags); } if (log.isDebugEnabled()) { log.debugf("Metric registry @%x contains %d metrics. Registered %d metrics for ObjectName \"%s\"", System.identityHashCode(registry), registry.getMetrics().size(), metricCounter, objectName); } }

Target:
public void register(ResourceDMBean resourceDMBean) { MetricRegistry registry = getRegistry(); ObjectName objectName = resourceDMBean.getObjectName(); int metricCounter = 0; if (log.isTraceEnabled()) { log.tracef("Metric registry @%x contains %d metrics. Registering metrics for ObjectName \"%s\" ...", System.identityHashCode(registry), registry.getMetrics().size(), objectName); } MBeanInfo mBeanInfo = resourceDMBean.getMBeanInfo(); MBeanAttributeInfo[] mBeanAttributes = mBeanInfo.getAttributes(); Tag[] tags = ObjectNameMapper.makeTags(objectName); for (MBeanAttributeInfo attr : mBeanAttributes) { if (!attr.isReadable()) { continue; } String attrName = attr.getName(); Supplier valueSupplier; try { valueSupplier = resourceDMBean.getAttributeValueSupplier(attrName); if (valueSupplier == null) { continue; } } catch (AttributeNotFoundException e) { throw new IllegalStateException(e); } Gauge<Number> gaugeMetric = () -> (Number) valueSupplier.get(); String metricName = ObjectNameMapper.makeMetricName(objectName, attrName); Metadata metadata = new MetadataBuilder() .withType(MetricType.GAUGE) .withName(metricName) .withDisplayName(attr.getName()) .withDescription(attr.getDescription()) .build(); if (log.isTraceEnabled()) { log.tracef("Registering metric %s with tags %s", metricName, Arrays.toString(tags)); metricCounter++; } registry.register(metadata, gaugeMetric, tags); } if (log.isTraceEnabled()) { log.tracef("Metric registry @%x contains %d metrics. Registered %d metrics for ObjectName \"%s\"", System.identityHashCode(registry), registry.getMetrics().size(), metricCounter, objectName); } }