diff options
author | Ivan Topolnjak <ivantopo@gmail.com> | 2017-12-12 00:33:36 +0100 |
---|---|---|
committer | Ivan Topolnjak <ivantopo@gmail.com> | 2017-12-12 00:33:36 +0100 |
commit | 1860d08fdc3fde314e18c74f745c2861178388a7 (patch) | |
tree | 53c74cc86f0bc7d70e2e0db4c05dfd2123416560 /kamon-core/src/main/scala/kamon/ReporterRegistry.scala | |
parent | a302c285f7950e1125094fe69a892afa574ea90b (diff) | |
download | Kamon-1860d08fdc3fde314e18c74f745c2861178388a7.tar.gz Kamon-1860d08fdc3fde314e18c74f745c2861178388a7.tar.bz2 Kamon-1860d08fdc3fde314e18c74f745c2861178388a7.zip |
rename TickSnapshot to PeriodSnapshot, use Instant instead of plain Longs
Diffstat (limited to 'kamon-core/src/main/scala/kamon/ReporterRegistry.scala')
-rw-r--r-- | kamon-core/src/main/scala/kamon/ReporterRegistry.scala | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/kamon-core/src/main/scala/kamon/ReporterRegistry.scala b/kamon-core/src/main/scala/kamon/ReporterRegistry.scala index 7d05ab92..89bafa36 100644 --- a/kamon-core/src/main/scala/kamon/ReporterRegistry.scala +++ b/kamon-core/src/main/scala/kamon/ReporterRegistry.scala @@ -15,7 +15,7 @@ package kamon -import java.time.Duration +import java.time.{Duration, Instant} import java.util.concurrent.atomic.{AtomicLong, AtomicReference} import java.util.concurrent._ @@ -40,7 +40,7 @@ sealed trait Reporter { } trait MetricReporter extends Reporter { - def reportTickSnapshot(snapshot: TickSnapshot): Unit + def reportPeriodSnapshot(snapshot: PeriodSnapshot): Unit } trait SpanReporter extends Reporter { @@ -321,12 +321,13 @@ object ReporterRegistry { private class MetricReporterTicker(snapshotGenerator: MetricsSnapshotGenerator, reporterEntries: TrieMap[Long, MetricReporterEntry]) extends Runnable { val logger = LoggerFactory.getLogger(classOf[MetricReporterTicker]) - var lastTick = System.currentTimeMillis() + var lastInstant = Instant.now() def run(): Unit = try { - val currentTick = System.currentTimeMillis() - val tickSnapshot = TickSnapshot( - interval = Interval(lastTick, currentTick), + val currentInstant = Instant.now() + val tickSnapshot = PeriodSnapshot( + from = lastInstant, + to = currentInstant, metrics = snapshotGenerator.snapshot() ) @@ -334,7 +335,7 @@ object ReporterRegistry { Future { Try { if (entry.isActive) - entry.reporter.reportTickSnapshot(tickSnapshot) + entry.reporter.reportPeriodSnapshot(tickSnapshot) }.failed.foreach { error => logger.error(s"Reporter [${entry.name}] failed to process a metrics tick.", error) @@ -343,7 +344,7 @@ object ReporterRegistry { }(entry.executionContext) } - lastTick = currentTick + lastInstant = currentInstant } catch { case NonFatal(t) => logger.error("Error while running a tick", t) |