Skip to content

Commit

Permalink
Corrects collection loop period (#323)
Browse files Browse the repository at this point in the history
  • Loading branch information
prognant authored Sep 9, 2020
1 parent 450ffd8 commit d27e516
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/main/java/org/datadog/jmxfetch/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -484,9 +484,15 @@ void start() {
// Sleep until next collection
try {
long loopPeriod = appConfig.getCheckPeriod();
long sleepPeriod = (duration > loopPeriod) ? loopPeriod : loopPeriod - duration;
log.debug("Sleeping for " + loopPeriod + " ms.");
Thread.sleep(loopPeriod);
long sleepPeriod = loopPeriod - duration;
if (sleepPeriod <= 0) {
log.debug(
"The collection cycle took longer that the configured check period,"
+ " the next cycle will start immediatly");
} else {
log.debug("Sleeping for " + sleepPeriod + " ms.");
Thread.sleep(sleepPeriod);
}
} catch (InterruptedException e) {
log.warn(e.getMessage(), e);
}
Expand Down

0 comments on commit d27e516

Please sign in to comment.