diff options
author | Ivan Topolnjak <ivantopo@gmail.com> | 2017-12-12 15:00:59 +0100 |
---|---|---|
committer | Ivan Topolnjak <ivantopo@gmail.com> | 2017-12-13 00:48:38 +0100 |
commit | 686040cb569283667b967494be4a7088ef35964c (patch) | |
tree | 95873e59bad8c859a14f55a1cc42758c87901d26 /kamon-core/src/main/scala/kamon/ReporterRegistry.scala | |
parent | 66cf166772712267aac922c51ded90c7dec3bdd5 (diff) | |
download | Kamon-686040cb569283667b967494be4a7088ef35964c.tar.gz Kamon-686040cb569283667b967494be4a7088ef35964c.tar.bz2 Kamon-686040cb569283667b967494be4a7088ef35964c.zip |
use a specialized java.time.Clock exposed through the Kamon companion object
Diffstat (limited to 'kamon-core/src/main/scala/kamon/ReporterRegistry.scala')
-rw-r--r-- | kamon-core/src/main/scala/kamon/ReporterRegistry.scala | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/kamon-core/src/main/scala/kamon/ReporterRegistry.scala b/kamon-core/src/main/scala/kamon/ReporterRegistry.scala index 89bafa36..55733294 100644 --- a/kamon-core/src/main/scala/kamon/ReporterRegistry.scala +++ b/kamon-core/src/main/scala/kamon/ReporterRegistry.scala @@ -23,7 +23,7 @@ import com.typesafe.config.Config import kamon.metric._ import kamon.trace.Span import kamon.trace.Span.FinishedSpan -import kamon.util.{DynamicAccess, Registration} +import kamon.util.{Clock, DynamicAccess, Registration} import org.slf4j.LoggerFactory import scala.concurrent.{ExecutionContext, ExecutionContextExecutorService, Future} @@ -64,7 +64,7 @@ object ReporterRegistry { def reportSpan(finishedSpan: FinishedSpan): Unit } - private[kamon] class Default(metrics: MetricsSnapshotGenerator, initialConfig: Config) extends ReporterRegistry with SpanSink { + private[kamon] class Default(metrics: MetricsSnapshotGenerator, initialConfig: Config, clock: Clock) extends ReporterRegistry with SpanSink { private val logger = LoggerFactory.getLogger(classOf[ReporterRegistry]) private val registryExecutionContext = Executors.newScheduledThreadPool(2, threadFactory("kamon-reporter-registry")) private val reporterCounter = new AtomicLong(0L) @@ -247,7 +247,7 @@ object ReporterRegistry { } else tickIntervalMillis registryExecutionContext.scheduleAtFixedRate( - new MetricReporterTicker(metrics, metricReporters), initialDelay, tickIntervalMillis, TimeUnit.MILLISECONDS + new MetricReporterTicker(metrics, metricReporters, clock), initialDelay, tickIntervalMillis, TimeUnit.MILLISECONDS ) } } @@ -319,12 +319,14 @@ object ReporterRegistry { val buffer = new ArrayBlockingQueue[Span.FinishedSpan](bufferCapacity) } - private class MetricReporterTicker(snapshotGenerator: MetricsSnapshotGenerator, reporterEntries: TrieMap[Long, MetricReporterEntry]) extends Runnable { + private class MetricReporterTicker(snapshotGenerator: MetricsSnapshotGenerator, reporterEntries: TrieMap[Long, MetricReporterEntry], + clock: Clock) extends Runnable { + val logger = LoggerFactory.getLogger(classOf[MetricReporterTicker]) - var lastInstant = Instant.now() + var lastInstant = Instant.now(clock) def run(): Unit = try { - val currentInstant = Instant.now() + val currentInstant = Instant.now(clock) val tickSnapshot = PeriodSnapshot( from = lastInstant, to = currentInstant, |