@Test public void collect() { AtomicBoolean executed = new AtomicBoolean(false); TestStatisticCollector statisticCollector = new TestStatisticCollector((t, s) -> { if (retries.get() >= 0) Assert.assertEquals("foo[name=value]", s); else Assert.assertEquals("foo[name=value], delayed[name=value]", s); executed.set(true); }); statisticCollector.register(new TestStatistic("foo")); statisticCollector.delayRegister(this::createTestStatistic); for (int i = 0; i < RETRIES_COUNT; i++) statisticCollector.collect(); Assert.assertTrue(executed.get()); }
public void collect() { processDelayedRegisterStatistics(); for (int i = 0; i < statistics.size(); i++) { AbstractStatistic statistic = statistics.get(i); try { statistic.collect(sink); } catch (Throwable ignored) { } } if (printer != null) printer.accept(System.currentTimeMillis(), sink.flush()); }
StatisticCollector { public void collect() { processDelayedRegisterStatistics(); for (int i = 0; i < statistics.size(); i++) { AbstractStatistic statistic = statistics.get(i); try { statistic.collect(sink); } catch (Throwable ignored) { } } if (printer != null) printer.accept(System.currentTimeMillis(), sink.flush()); } }
StatisticCollector { public void collect() { processDelayedRegisterStatistics(); for (int i = 0; i < statistics.size(); i++) { AbstractStatistic statistic = statistics.get(i); try { statistic.collect(sink); } catch (Throwable ignored) { } } if (printer != null) printer.accept(System.currentTimeMillis(), sink.flush()); } StatisticCollector(BiConsumer<Long, T> printer, StatisticsSink<T> sink); }
StatisticCollector { public void collect() { processDelayedRegisterStatistics(); for (int i = 0; i < statistics.size(); i++) { AbstractStatistic statistic = statistics.get(i); try { statistic.collect(sink); } catch (Throwable ignored) { } } if (printer != null) printer.accept(System.currentTimeMillis(), sink.flush()); } StatisticCollector(BiConsumer<Long, T> printer, StatisticsSink<T> sink); void register(AbstractStatistic statistic); void delayRegister(Supplier<AbstractStatistic> registerCallback); void collect(); void unregister(); }
StatisticCollector { public void collect() { processDelayedRegisterStatistics(); for (int i = 0; i < statistics.size(); i++) { AbstractStatistic statistic = statistics.get(i); try { statistic.collect(sink); } catch (Throwable ignored) { } } if (printer != null) printer.accept(System.currentTimeMillis(), sink.flush()); } StatisticCollector(BiConsumer<Long, T> printer, StatisticsSink<T> sink); void register(AbstractStatistic statistic); void delayRegister(Supplier<AbstractStatistic> registerCallback); void collect(); void unregister();  }