public static MetricName getMetricName(
        String group,
        String typeName,
        String name,
        LinkedHashMap<String, String> tags
    ) {
        StringBuilder nameBuilder = new StringBuilder();
        nameBuilder.append(group);
        nameBuilder.append(":type=");
        nameBuilder.append(typeName);

        if (!name.isEmpty()) {
            nameBuilder.append(",name=");
            nameBuilder.append(name);
        }

        String scope = toScope(tags).orElse(null);
        Optional<String> tagsName = toMBeanName(tags);
        tagsName.ifPresent(nameBuilder::append);

        return new MetricName(group, typeName, name, scope, nameBuilder.toString());
    }
convenience method to replace {@link com.yammer.metrics.Metrics#defaultRegistry()}
server-common/src/main/java/org/apache/kafka/server/metrics/KafkaYammerMetrics.java