@Test public void testAllScopes() { JsonExporter exporter = new JsonExporter(); MetricRegistries.get(MetricRegistry.Type.APPLICATION).counter("c1"); MetricRegistries.get(MetricRegistry.Type.BASE).counter("b1"); MetricRegistries.get(MetricRegistry.Type.VENDOR).counter("a1"); String result = exporter.exportAllScopes().toString(); JsonObject json = Json.createReader(new StringReader(result)).read().asJsonObject(); assertEquals(0, json.getJsonObject("application").getInt("c1")); assertEquals(0, json.getJsonObject("base").getInt("b1")); assertEquals(0, json.getJsonObject("vendor").getInt("a1")); }
@Override public StringBuilder exportAllScopes() { JsonObjectBuilder root = JsonProviderHolder.get().createObjectBuilder(); root.add("base", exportOneRegistry(MetricRegistries.get(MetricRegistry.Type.BASE))); root.add("vendor", exportOneRegistry(MetricRegistries.get(MetricRegistry.Type.VENDOR))); root.add("application", exportOneRegistry(MetricRegistries.get(MetricRegistry.Type.APPLICATION))); return stringify(root.build()); }
JsonExporter implements Exporter { @Override public StringBuilder exportAllScopes() { JsonObjectBuilder root = JsonProviderHolder.get().createObjectBuilder(); root.add("base", exportOneRegistry(MetricRegistries.get(MetricRegistry.Type.BASE))); root.add("vendor", exportOneRegistry(MetricRegistries.get(MetricRegistry.Type.VENDOR))); root.add("application", exportOneRegistry(MetricRegistries.get(MetricRegistry.Type.APPLICATION))); return stringify(root.build()); } }
JsonExporter implements Exporter { @Override public StringBuilder exportAllScopes() { JsonObjectBuilder root = JsonProviderHolder.get().createObjectBuilder(); root.add("base", exportOneRegistry(MetricRegistries.get(MetricRegistry.Type.BASE))); root.add("vendor", exportOneRegistry(MetricRegistries.get(MetricRegistry.Type.VENDOR))); root.add("application", exportOneRegistry(MetricRegistries.get(MetricRegistry.Type.APPLICATION))); return stringify(root.build()); } JsonExporter(); }
JsonExporter implements Exporter { @Override public StringBuilder exportAllScopes() { JsonObjectBuilder root = JsonProviderHolder.get().createObjectBuilder(); root.add("base", exportOneRegistry(MetricRegistries.get(MetricRegistry.Type.BASE))); root.add("vendor", exportOneRegistry(MetricRegistries.get(MetricRegistry.Type.VENDOR))); root.add("application", exportOneRegistry(MetricRegistries.get(MetricRegistry.Type.APPLICATION))); return stringify(root.build()); } JsonExporter(); @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(); }
JsonExporter implements Exporter { @Override public StringBuilder exportAllScopes() { JsonObjectBuilder root = JsonProviderHolder.get().createObjectBuilder(); root.add("base", exportOneRegistry(MetricRegistries.get(MetricRegistry.Type.BASE))); root.add("vendor", exportOneRegistry(MetricRegistries.get(MetricRegistry.Type.VENDOR))); root.add("application", exportOneRegistry(MetricRegistries.get(MetricRegistry.Type.APPLICATION))); return stringify(root.build()); } JsonExporter(); @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();  }