@Test public void statistics_disabled() { DurationStatistics statistics = new DurationStatistics(sensorContext.config()); fillStatistics(statistics); statistics.log(); assertThat(logTester.logs(LoggerLevel.INFO)).isEmpty(); }
void log() { if (recordStat) { StringBuilder out = new StringBuilder(); DecimalFormatSymbols symbols = new DecimalFormatSymbols(Locale.ROOT); symbols.setGroupingSeparator('\''); NumberFormat format = new DecimalFormat("#,###", symbols); out.append("Duration Statistics"); stats.entrySet().stream() .sorted((a, b) -> Long.compare(b.getValue().get(), a.getValue().get())) .forEach(e -> out.append(", ") .append(e.getKey()) .append(" ") .append(format.format(e.getValue().get() / 1_000_000L)) .append(" ms")); LOG.info(out.toString()); } }
DurationStatistics { void log() { if (recordStat) { StringBuilder out = new StringBuilder(); DecimalFormatSymbols symbols = new DecimalFormatSymbols(Locale.ROOT); symbols.setGroupingSeparator('\''); NumberFormat format = new DecimalFormat("#,###", symbols); out.append("Duration Statistics"); stats.entrySet().stream() .sorted((a, b) -> Long.compare(b.getValue().get(), a.getValue().get())) .forEach(e -> out.append(", ") .append(e.getKey()) .append(" ") .append(format.format(e.getValue().get() / 1_000_000L)) .append(" ms")); LOG.info(out.toString()); } } }
DurationStatistics { void log() { if (recordStat) { StringBuilder out = new StringBuilder(); DecimalFormatSymbols symbols = new DecimalFormatSymbols(Locale.ROOT); symbols.setGroupingSeparator('\''); NumberFormat format = new DecimalFormat("#,###", symbols); out.append("Duration Statistics"); stats.entrySet().stream() .sorted((a, b) -> Long.compare(b.getValue().get(), a.getValue().get())) .forEach(e -> out.append(", ") .append(e.getKey()) .append(" ") .append(format.format(e.getValue().get() / 1_000_000L)) .append(" ms")); LOG.info(out.toString()); } } DurationStatistics(Configuration config); }
DurationStatistics { void log() { if (recordStat) { StringBuilder out = new StringBuilder(); DecimalFormatSymbols symbols = new DecimalFormatSymbols(Locale.ROOT); symbols.setGroupingSeparator('\''); NumberFormat format = new DecimalFormat("#,###", symbols); out.append("Duration Statistics"); stats.entrySet().stream() .sorted((a, b) -> Long.compare(b.getValue().get(), a.getValue().get())) .forEach(e -> out.append(", ") .append(e.getKey()) .append(" ") .append(format.format(e.getValue().get() / 1_000_000L)) .append(" ms")); LOG.info(out.toString()); } } DurationStatistics(Configuration config);  }
DurationStatistics { void log() { if (recordStat) { StringBuilder out = new StringBuilder(); DecimalFormatSymbols symbols = new DecimalFormatSymbols(Locale.ROOT); symbols.setGroupingSeparator('\''); NumberFormat format = new DecimalFormat("#,###", symbols); out.append("Duration Statistics"); stats.entrySet().stream() .sorted((a, b) -> Long.compare(b.getValue().get(), a.getValue().get())) .forEach(e -> out.append(", ") .append(e.getKey()) .append(" ") .append(format.format(e.getValue().get() / 1_000_000L)) .append(" ms")); LOG.info(out.toString()); } } DurationStatistics(Configuration config);   }