Source:
MetricData(MetricDescriptor descriptor, String instanceNameEscaped, String domainPrefix) { StringBuilder mBeanTags = new StringBuilder(); StringBuilder moduleBuilder = new StringBuilder(); String module = null; metric = descriptor.metric(); ProbeUnit descriptorUnit = descriptor.unit(); unit = descriptorUnit != null ? descriptorUnit.name() : "unknown"; MutableInteger tagCnt = new MutableInteger(); for (int i = 0; i < descriptor.tagCount(); i++) { String tag = descriptor.tag(i); String tagValue = descriptor.tagValue(i); if ("module".equals(tag)) { moduleBuilder.append(tagValue); } else { if (mBeanTags.length() > 0) { mBeanTags.append(','); } int newTagIdx = tagCnt.getAndInc(); mBeanTags.append("tag").append(newTagIdx).append('=') .append(escapeObjectNameValue(tag + "=" + tagValue)); } } if (moduleBuilder.length() > 0) { module = moduleBuilder.toString(); } String discriminator = descriptor.discriminator(); String discriminatorValue = descriptor.discriminatorValue(); if (discriminator != null && discriminatorValue != null) { int newTagIdx = tagCnt.getAndInc(); mBeanTags.append("tag").append(newTagIdx).append("=") .append(escapeObjectNameValue(discriminator + "=" + discriminatorValue)); } assert metric != null : "metric == null"; StringBuilder objectNameStr = new StringBuilder(mBeanTags.length() + (1 << 3 << 3)); objectNameStr.append(domainPrefix); if (module != null) { objectNameStr.append('.').append(module); } objectNameStr.append(":type=Metrics"); objectNameStr.append(",instance=").append(instanceNameEscaped); if (descriptor.prefix() != null) { objectNameStr.append(",prefix=").append(escapeObjectNameValue(descriptor.prefix())); } if (mBeanTags.length() > 0) { objectNameStr.append(',').append(mBeanTags); } try { objectName = new ObjectName(objectNameStr.toString()); } catch (MalformedObjectNameException e) { throw new RuntimeException(e); } }

Target:
MetricData(MetricDescriptor descriptor, String instanceNameEscaped, String domainPrefix) { StringBuilder mBeanTags = new StringBuilder(); StringBuilder moduleBuilder = new StringBuilder(); String module = null; metric = descriptor.metric(); ProbeUnit descriptorUnit = descriptor.unit(); unit = descriptorUnit != null ? descriptorUnit.name() : "unknown"; MutableInteger tagCnt = new MutableInteger(); for (int i = 0; i < descriptor.tagCount(); i++) { String tag = descriptor.tag(i); String tagValue = descriptor.tagValue(i); if ("module".equals(tag)) { moduleBuilder.append(tagValue); } else { if (mBeanTags.length() > 0) { mBeanTags.append(','); } int newTagIdx = tagCnt.getAndInc(); mBeanTags.append("tag").append(newTagIdx).append('=') .append(escapeObjectNameValue(tag + "=" + tagValue)); } } if (moduleBuilder.length() > 0) { module = moduleBuilder.toString(); } String discriminator = descriptor.discriminator(); String discriminatorValue = descriptor.discriminatorValue(); if (discriminator != null && discriminatorValue != null) { if (mBeanTags.length() > 0) { mBeanTags.append(','); } int newTagIdx = tagCnt.getAndInc(); mBeanTags.append("tag").append(newTagIdx).append("=") .append(escapeObjectNameValue(discriminator + "=" + discriminatorValue)); } assert metric != null : "metric == null"; StringBuilder objectNameStr = new StringBuilder(mBeanTags.length() + (1 << 3 << 3)); objectNameStr.append(domainPrefix); if (module != null) { objectNameStr.append('.').append(module); } objectNameStr.append(":type=Metrics"); objectNameStr.append(",instance=").append(instanceNameEscaped); if (descriptor.prefix() != null) { objectNameStr.append(",prefix=").append(escapeObjectNameValue(descriptor.prefix())); } if (mBeanTags.length() > 0) { objectNameStr.append(',').append(mBeanTags); } try { objectName = new ObjectName(objectNameStr.toString()); } catch (MalformedObjectNameException e) { throw new RuntimeException(e); } }