BatchCallback (final @NotNull Meter meter, final @NotNull String flusherName) { final ObservableLongMeasurement spentQuotaCounter = meter.counterBuilder(flusherName + ".totalContentionQuotaSpent") .setUnit("1") .setDescription("How many contention flush met in a period") .buildObserver(); final ObservableLongMeasurement flushingTimeCounter = meter.counterBuilder(flusherName + ".totalFlushingTimeUs") .setUnit("microseconds") .setDescription("Total time spent by flushing in a period") .buildObserver(); final ObservableLongMeasurement flushesCounter = meter.counterBuilder(flusherName + ".totalFlushes") .setUnit("1") .setDescription("How many flushes done in a period (both: regular and retried)") .buildObserver(); final ObservableLongMeasurement retriedFlushesCounter = meter.counterBuilder(flusherName + ".totalFlushesRetried") .setUnit("1") .setDescription("How many flushes retried in a period") .buildObserver(); return meter.batchCallback( () -> { spentQuotaCounter.record(totalQuotaSpent.longValue()); flushingTimeCounter.record(totalFlushingTimeUs.longValue()); flushesCounter.record(totalFlushes.longValue()); retriedFlushesCounter.record(totalFlushesRetried.longValue()); }, spentQuotaCounter, flushingTimeCounter, flushesCounter, retriedFlushesCounter ); }