diff options
Diffstat (limited to 'kamon-core/src/main/scala/kamon/ReporterRegistry.scala')
-rw-r--r-- | kamon-core/src/main/scala/kamon/ReporterRegistry.scala | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/kamon-core/src/main/scala/kamon/ReporterRegistry.scala b/kamon-core/src/main/scala/kamon/ReporterRegistry.scala index 55733294..67cfbe4e 100644 --- a/kamon-core/src/main/scala/kamon/ReporterRegistry.scala +++ b/kamon-core/src/main/scala/kamon/ReporterRegistry.scala @@ -234,15 +234,9 @@ object ReporterRegistry { metricReporterTickerSchedule.set { val initialDelay = if(registryConfiguration.optimisticMetricTickAlignment) { - val minimumInitialDelay = 2.seconds.toMillis - val currentTimestamp = System.currentTimeMillis() - val roundCurrentTick = Math.floor(currentTimestamp.toDouble / tickIntervalMillis.toDouble).toLong - val roundCurrentTimestamp = roundCurrentTick * tickIntervalMillis - - if(roundCurrentTimestamp - currentTimestamp >= minimumInitialDelay) - roundCurrentTimestamp - currentTimestamp - else - (roundCurrentTimestamp + tickIntervalMillis) - currentTimestamp + val now = clock.instant() + val nextTick = Clock.nextTick(now, registryConfiguration.metricTickInterval) + Duration.between(now, nextTick).toMillis } else tickIntervalMillis |