### Question:
OpenMetricsExporter implements Exporter { @Override public StringBuilder exportAllScopes() { StringBuilder sb = new StringBuilder(); for (MetricRegistry.Type scope : MetricRegistry.Type.values()) { alreadyExportedNames.set(new HashSet<>()); getEntriesForScope(scope, sb); alreadyExportedNames.set(null); } return sb; } OpenMetricsExporter(); @Override StringBuilder exportOneScope(MetricRegistry.Type scope); @Override StringBuilder exportAllScopes(); @Override StringBuilder exportOneMetric(MetricRegistry.Type scope, MetricID metricID); @Override StringBuilder exportMetricsByName(MetricRegistry.Type scope, String name); @Override String getContentType(); static String quoteHelpText(String value); static String quoteValue(String value); static final String SMALLRYE_METRICS_USE_PREFIX_FOR_SCOPE; }### Answer:
@Test public void testMetricsWhereKeysAreDifferentFromNames() { OpenMetricsExporter exporter = new OpenMetricsExporter(); MetricRegistry registry = MetricRegistries.get(MetricRegistry.Type.APPLICATION); Metadata metadata = Metadata.builder() .withName("metric.a") .withType(MetricType.COUNTER) .withDescription("Great") .build(); Tag tag1 = new Tag("tag1", "value1"); Tag tag2 = new Tag("tag1", "value2"); registry.counter(metadata, tag1); registry.counter(metadata, tag2); String result = exporter.exportAllScopes().toString(); System.out.println(result); assertHasHelpLineExactlyOnce(result, "application_metric_a_total", "Great"); assertHasTypeLineExactlyOnce(result, "application_metric_a_total", "counter"); }