Metrics { public Flowable<MetricsDump> dumpContinuously(Duration interval) { if (interval.toMillis() <= 0) { throw new IllegalArgumentException("interval must be positive"); } return Flowable .interval(interval.toMillis(), interval.toMillis(), TimeUnit.MILLISECONDS) .map(count -> dump()); }  MetricsDump dump(); void addAdditionalInfoForDumps(String key, String value); Flowable<MetricsDump> dumpContinuously(Duration interval); void dumpContinuouslyToLog(Duration dumpInterval); void dumpToLog(); void register(String metricName, T metric); void register(T metric, String idPathFirst, String... idPathRemainder); boolean remove(String metricName); boolean remove(String idPathFirst, String... idPathRemainder); Meter getMeter(String metricName); Meter getMeter(String idPathFirst, String... idPathRemainder); Counter getCounter(String metricName); Counter getCounter(String idPathFirst, String... idPathRemainder); Timer getTimer(String metricName); Timer getTimer(String idPathFirst, String... idPathRemainder); Histogram getHistogram(String metricName); Histogram getHistogram(String idPathFirst, String... idPathRemainder); Gauge getGauge(String metricName); Gauge getGauge(String idPathFirst, String... idPathRemainder); Map<String, Metric> getMetrics(); static String name(String idPathFirst, String... idPathRemainder); final MetricRegistry metricRegistry; }
@Test void continuousDumpNeedsIntervalLargerThanZero() { IllegalArgumentException ex = assertThrows(IllegalArgumentException.class, () -> sut.dumpContinuously(Duration.ofSeconds(-1))); assertThat(ex.getMessage(),containsString("interval must be positive")); ex = assertThrows(IllegalArgumentException.class, () -> sut.dumpContinuously(Duration.ZERO)); assertThat(ex.getMessage(),containsString("interval must be positive")); }