diff --git a/metrics-core/src/main/java/com/codahale/metrics/ScheduledReporter.java b/metrics-core/src/main/java/com/codahale/metrics/ScheduledReporter.java index 304cfb3a26..5821df1c8b 100644 --- a/metrics-core/src/main/java/com/codahale/metrics/ScheduledReporter.java +++ b/metrics-core/src/main/java/com/codahale/metrics/ScheduledReporter.java @@ -166,7 +166,19 @@ synchronized void start(long initialDelay, long period, TimeUnit unit, Runnable throw new IllegalArgumentException("Reporter already started"); } - this.scheduledFuture = executor.scheduleWithFixedDelay(runnable, initialDelay, period, unit); + this.scheduledFuture = getScheduledFuture(initialDelay, period, unit, runnable); + } + + + /** + * Schedule the task, and return a future. + * The current implementation uses scheduleWithFixedDelay, replacing scheduleWithFixedRate. This avoids queueing issues, but may + * cause some reporters to skip metrics, as scheduleWithFixedDelay introduces a growing delta from the original start point. + * + * Overriding this in a subclass to revert to the old behavior is permitted. + */ + protected ScheduledFuture getScheduledFuture(long initialDelay, long period, TimeUnit unit, Runnable runnable) { + return executor.scheduleWithFixedDelay(runnable, initialDelay, period, unit); } /**