MetricFilter filter,
List<Metric> metrics,
ObjectName name)
throws JMException, IOException {
// Create tags from the object name
TagList tags = createTagList(name);
MBeanInfo info = con.getMBeanInfo(name);
MBeanAttributeInfo[] attrInfos = info.getAttributes();
// Restrict to attributes that match the filter
List<String> matchingNames = Lists.newArrayList();
for (MBeanAttributeInfo attrInfo : attrInfos) {
String attrName = attrInfo.getName();
if (filter.matches(new MonitorConfig.Builder(attrName).withTags(tags).build())) {
matchingNames.add(attrName);
}
}
List<Attribute> attributeList = safelyLoadAttributes(con, name, matchingNames);
for (Attribute attr : attributeList) {
String attrName = attr.getName();
Object obj = attr.getValue();
if (obj instanceof CompositeData) {
Map<String, Object> values = Maps.newHashMap();
extractValues(null, values, (CompositeData) obj);
for (Map.Entry<String, Object> e : values.entrySet()) {
String key = e.getKey();
TagList newTags = SortedTagList.builder()
.withTags(tags)
.withTag(COMPOSITE_PATH_KEY, key)
.build();
if (filter.matches(MonitorConfig.builder(attrName).withTags(newTags).build())) {
addMetric(metrics, attrName, newTags, e.getValue());