Skip to content

Commit

Permalink
Allow override of scheduler in ScheduledReporter (#2931)
Browse files Browse the repository at this point in the history
#1524 introduced a fix to queuing issues and ends up doing atFixedDelay rather than atFixedRate.

Issues with binning exist in Graphite (and probably others).

See #2664
  • Loading branch information
mikebell90 committed Dec 9, 2022
1 parent d6efec7 commit 6256089
Showing 1 changed file with 13 additions and 1 deletion.
Expand Up @@ -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);
}

/**
Expand Down

0 comments on commit 6256089

Please sign in to comment.