@Test public void testAppendingOfTotal() { OpenMetricsExporter exporter = new OpenMetricsExporter(); MetricRegistry registry = MetricRegistries.get(MetricRegistry.Type.APPLICATION); Tag tag = new Tag("a", "b"); registry.counter("counter1", tag); String export = exporter.exportOneMetric(MetricRegistry.Type.APPLICATION, new MetricID("counter1", tag)).toString(); assertThat(export, containsString("application_counter1_total{a=\"b\"}")); registry.counter("counter2_total", tag); export = exporter.exportOneMetric(MetricRegistry.Type.APPLICATION, new MetricID("counter2_total", tag)).toString(); assertThat(export, containsString("application_counter2_total{a=\"b\"}")); }
@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; }