diff options
author | Ivan Topolnjak <ivantopo@gmail.com> | 2017-12-18 13:21:10 +0100 |
---|---|---|
committer | Ivan Topolnjak <ivantopo@gmail.com> | 2017-12-18 13:27:37 +0100 |
commit | ba6736eab2b5a229c2ba7263591c4e6c7c2db0b1 (patch) | |
tree | db9b12941e4172db6c3320d2728a3fb8ef2130f0 /kamon-core | |
parent | c3964e95c09914a6a1b4039e10e630074744f4e9 (diff) | |
download | Kamon-ba6736eab2b5a229c2ba7263591c4e6c7c2db0b1.tar.gz Kamon-ba6736eab2b5a229c2ba7263591c4e6c7c2db0b1.tar.bz2 Kamon-ba6736eab2b5a229c2ba7263591c4e6c7c2db0b1.zip |
use clock utilities to align metric reporting ticks
Diffstat (limited to 'kamon-core')
-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 |