@Test public void testHelpLineQuoting() { OpenMetricsExporter exporter = new OpenMetricsExporter(); MetricRegistry registry = MetricRegistries.get(MetricRegistry.Type.APPLICATION); Metadata metadata = Metadata.builder() .withName("counter_with_complicated_description") .withDescription("hhh\\ggg\\nfff\\").build(); registry.counter(metadata); String export = exporter .exportOneMetric(MetricRegistry.Type.APPLICATION, new MetricID("counter_with_complicated_description")) .toString(); assertThat(export, containsString("# HELP application_counter_with_complicated_description_total hhh\\\\ggg\\nfff\\\\")); metadata = Metadata.builder() .withName("counter_with_complicated_description_2") .withDescription("description with \"quotes\"").build(); registry.counter(metadata); export = exporter .exportOneMetric(MetricRegistry.Type.APPLICATION, new MetricID("counter_with_complicated_description_2")) .toString(); assertThat(export, containsString("# HELP application_counter_with_complicated_description_2_total description with \"quotes\"")); }
@Override public StringBuilder exportOneMetric(MetricRegistry.Type scope, MetricID metricID) { alreadyExportedNames.set(new HashSet<>()); MetricRegistry registry = MetricRegistries.get(scope); Map<MetricID, Metric> metricMap = registry.getMetrics(); Metric m = metricMap.get(metricID); Map<MetricID, Metric> outMap = new HashMap<>(1); outMap.put(metricID, m); StringBuilder sb = new StringBuilder(); exposeEntries(scope, sb, registry, outMap); alreadyExportedNames.set(null); return sb; }
OpenMetricsExporter implements Exporter { @Override public StringBuilder exportOneMetric(MetricRegistry.Type scope, MetricID metricID) { alreadyExportedNames.set(new HashSet<>()); MetricRegistry registry = MetricRegistries.get(scope); Map<MetricID, Metric> metricMap = registry.getMetrics(); Metric m = metricMap.get(metricID); Map<MetricID, Metric> outMap = new HashMap<>(1); outMap.put(metricID, m); StringBuilder sb = new StringBuilder(); exposeEntries(scope, sb, registry, outMap); alreadyExportedNames.set(null); return sb; } }
OpenMetricsExporter implements Exporter { @Override public StringBuilder exportOneMetric(MetricRegistry.Type scope, MetricID metricID) { alreadyExportedNames.set(new HashSet<>()); MetricRegistry registry = MetricRegistries.get(scope); Map<MetricID, Metric> metricMap = registry.getMetrics(); Metric m = metricMap.get(metricID); Map<MetricID, Metric> outMap = new HashMap<>(1); outMap.put(metricID, m); StringBuilder sb = new StringBuilder(); exposeEntries(scope, sb, registry, outMap); alreadyExportedNames.set(null); return sb; } OpenMetricsExporter(); }
OpenMetricsExporter implements Exporter { @Override public StringBuilder exportOneMetric(MetricRegistry.Type scope, MetricID metricID) { alreadyExportedNames.set(new HashSet<>()); MetricRegistry registry = MetricRegistries.get(scope); Map<MetricID, Metric> metricMap = registry.getMetrics(); Metric m = metricMap.get(metricID); Map<MetricID, Metric> outMap = new HashMap<>(1); outMap.put(metricID, m); StringBuilder sb = new StringBuilder(); exposeEntries(scope, sb, registry, outMap); 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); }
OpenMetricsExporter implements Exporter { @Override public StringBuilder exportOneMetric(MetricRegistry.Type scope, MetricID metricID) { alreadyExportedNames.set(new HashSet<>()); MetricRegistry registry = MetricRegistries.get(scope); Map<MetricID, Metric> metricMap = registry.getMetrics(); Metric m = metricMap.get(metricID); Map<MetricID, Metric> outMap = new HashMap<>(1); outMap.put(metricID, m); StringBuilder sb = new StringBuilder(); exposeEntries(scope, sb, registry, outMap); 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; }