Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow override of scheduler #2931

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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