in agent/agent-tooling/src/main/java/com/microsoft/applicationinsights/agent/internal/perfcounter/AvailableJmxMetricLogger.java [158:191]
private static List<String> getNumericAttributes(MBeanAttributeInfo attribute, Object value) {
String attributeType = attribute.getType();
if (NUMERIC_ATTRIBUTE_TYPES.contains(attributeType) && value instanceof Number) {
return singletonList(attribute.getName());
}
if (BOOLEAN_ATTRIBUTE_TYPES.contains(attributeType) && value instanceof Boolean) {
return singletonList(attribute.getName());
}
if (attributeType.equals("java.lang.Object") && value instanceof Number) {
return singletonList(attribute.getName());
}
if (attributeType.equals("java.lang.String") && value instanceof String) {
try {
Double.parseDouble((String) value);
return singletonList(attribute.getName());
} catch (NumberFormatException e) {
// this is expected for non-numeric attributes
return emptyList();
}
}
if (attributeType.equals(CompositeData.class.getName())) {
Object openType = attribute.getDescriptor().getFieldValue("openType");
CompositeType compositeType = null;
if (openType instanceof CompositeType) {
compositeType = (CompositeType) openType;
} else if (openType == null && value instanceof CompositeDataSupport) {
compositeType = ((CompositeDataSupport) value).getCompositeType();
}
if (compositeType != null) {
return getCompositeTypeAttributeNames(attribute, value, compositeType);
}
}
return emptyList();
}