@Test public void createsMetricsJsonCorrectly() throws JsonProcessingException { MetricRegistry registry = new MetricRegistry(); registry.counter("styx.origins.status.200").inc(); registry.counter("styx.origins.status.500").inc(2); registry.counter("styx.error").inc(3); registry.counter("foo.bar").inc(4); registry.register("styx.mygauge", (Gauge<Integer>) () -> 123); String before = new ObjectMapper() .registerModule(new MetricsModule(SECONDS, MILLISECONDS, false)) .writeValueAsString(registry); String after = JsonReformatter.reformat(before); assertThat(after, matchesRegex(quote("{\n" + " \"counters\":{\n" + " \"foo.bar.count\":4,\n" + " \"styx\":{\n" + " \"error.count\":3,\n" + " \"origins.status\":{\n" + " \"200.count\":1,\n" + " \"500.count\":2\n" + " }\n" + " }\n" + " },\n" + " \"gauges.styx.mygauge.value\":123,\n" + " \"histograms\":{\n" + "\n" + " },\n" + " \"meters\":{\n" + "\n" + " },\n" + " \"timers\":{\n" + "\n" + " },\n" + " \"version\":\"") + "\\d+\\.\\d+\\.\\d+" + quote("\"\n" + "}"))); }
public static String reformat(String json) { try { return reformat0(json); } catch (IOException e) { throw new RuntimeException(e); } }
JsonReformatter { public static String reformat(String json) { try { return reformat0(json); } catch (IOException e) { throw new RuntimeException(e); } } }
JsonReformatter { public static String reformat(String json) { try { return reformat0(json); } catch (IOException e) { throw new RuntimeException(e); } } private  JsonReformatter(); }
JsonReformatter { public static String reformat(String json) { try { return reformat0(json); } catch (IOException e) { throw new RuntimeException(e); } } private  JsonReformatter(); static String reformat(String json); }
JsonReformatter { public static String reformat(String json) { try { return reformat0(json); } catch (IOException e) { throw new RuntimeException(e); } } private  JsonReformatter(); static String reformat(String json);  }