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"; AtomicInteger tagCnt = new AtomicInteger(); descriptor.readTags((tag, tagValue) -> { if ("module".equals(tag)) { moduleBuilder.append(tagValue); } else { if (mBeanTags.length() > 0) { mBeanTags.append(','); } int newTagIdx = tagCnt.getAndIncrement(); 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) { mBeanTags.append(escapeObjectNameValue(discriminator)) .append('=') .append(escapeObjectNameValue(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(); descriptor.readTags((tag, tagValue) -> { 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) { mBeanTags.append(escapeObjectNameValue(discriminator)) .append('=') .append(escapeObjectNameValue(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); } }