### Question:
OpenMetricsExporter implements Exporter { static String getOpenMetricsMetricName(String name) { String out = name; out = out.replace("__", USCORE); out = out.replaceAll("[^\\w]", USCORE); return out; } 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 metricNameConversion() { assertEquals("FRAG3", getOpenMetricsMetricName("FRAG3")); assertEquals("UNICAST3", getOpenMetricsMetricName("UNICAST3")); assertEquals("FOO_BAR", getOpenMetricsMetricName("FOO-BAR")); assertEquals("FooBAR", getOpenMetricsMetricName("FooBAR")); assertEquals("FooBar", getOpenMetricsMetricName("FooBar")); assertEquals("a_a", getOpenMetricsMetricName("a__a")); assertEquals("fooBar_blaBla", getOpenMetricsMetricName("fooBar_blaBla")); }
@Test public void testMetricNameQuoting() { assertEquals("zz", getOpenMetricsMetricName("zz")); assertEquals("_", getOpenMetricsMetricName("č")); assertEquals("__", getOpenMetricsMetricName("čž")); assertEquals("___", getOpenMetricsMetricName(":čž")); assertEquals("_", getOpenMetricsMetricName("__")); assertEquals("a__b", getOpenMetricsMetricName("a:_b")); assertEquals("hello_hello", getOpenMetricsMetricName("helloŘhello")); }