@Test public void getMetrics() { String response = endpoint.get("metrics").toString(); Assert.assertEquals(response, "[]"); registry.gauge("test.gauge", "foo", "bar", "abc", "def").set(42.0); response = endpoint.get("metrics").toString(); String expected = "[{name=test.gauge, tags={abc=def, foo=bar}, timestamp=0, value=42.0}]"; Assert.assertEquals(response, expected); }
private Object getMetrics() { List<Object> metrics = new ArrayList<>(); for (Meter meter : registry) { for (Measurement m : meter.measure()) { if (Double.isFinite(m.value())) { Map<String, Object> datapoint = new LinkedHashMap<>(); datapoint.put("name", m.id().name()); datapoint.put("tags", encodeTags(m.id())); datapoint.put("timestamp", m.timestamp()); datapoint.put("value", m.value()); metrics.add(datapoint); } } } return metrics; }
BaseServerEndpoint implements HttpEndpoint { private Object getMetrics() { List<Object> metrics = new ArrayList<>(); for (Meter meter : registry) { for (Measurement m : meter.measure()) { if (Double.isFinite(m.value())) { Map<String, Object> datapoint = new LinkedHashMap<>(); datapoint.put("name", m.id().name()); datapoint.put("tags", encodeTags(m.id())); datapoint.put("timestamp", m.timestamp()); datapoint.put("value", m.value()); metrics.add(datapoint); } } } return metrics; } }
BaseServerEndpoint implements HttpEndpoint { private Object getMetrics() { List<Object> metrics = new ArrayList<>(); for (Meter meter : registry) { for (Measurement m : meter.measure()) { if (Double.isFinite(m.value())) { Map<String, Object> datapoint = new LinkedHashMap<>(); datapoint.put("name", m.id().name()); datapoint.put("tags", encodeTags(m.id())); datapoint.put("timestamp", m.timestamp()); datapoint.put("value", m.value()); metrics.add(datapoint); } } } return metrics; } @Inject  BaseServerEndpoint(Registry registry); }
BaseServerEndpoint implements HttpEndpoint { private Object getMetrics() { List<Object> metrics = new ArrayList<>(); for (Meter meter : registry) { for (Measurement m : meter.measure()) { if (Double.isFinite(m.value())) { Map<String, Object> datapoint = new LinkedHashMap<>(); datapoint.put("name", m.id().name()); datapoint.put("tags", encodeTags(m.id())); datapoint.put("timestamp", m.timestamp()); datapoint.put("value", m.value()); metrics.add(datapoint); } } } return metrics; } @Inject  BaseServerEndpoint(Registry registry); @Override Object get(); @Override Object get(String path); }
BaseServerEndpoint implements HttpEndpoint { private Object getMetrics() { List<Object> metrics = new ArrayList<>(); for (Meter meter : registry) { for (Measurement m : meter.measure()) { if (Double.isFinite(m.value())) { Map<String, Object> datapoint = new LinkedHashMap<>(); datapoint.put("name", m.id().name()); datapoint.put("tags", encodeTags(m.id())); datapoint.put("timestamp", m.timestamp()); datapoint.put("value", m.value()); metrics.add(datapoint); } } } return metrics; } @Inject  BaseServerEndpoint(Registry registry); @Override Object get(); @Override Object get(String path);  }