diff options
Diffstat (limited to 'kamon-core/src/main')
-rw-r--r-- | kamon-core/src/main/scala/kamon/ReporterRegistry.scala | 17 | ||||
-rw-r--r-- | kamon-core/src/main/scala/kamon/metric/PeriodSnapshot.scala (renamed from kamon-core/src/main/scala/kamon/metric/TickSnapshot.scala) | 10 |
2 files changed, 15 insertions, 12 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) diff --git a/kamon-core/src/main/scala/kamon/metric/TickSnapshot.scala b/kamon-core/src/main/scala/kamon/metric/PeriodSnapshot.scala index 45666de1..50a5f778 100644 --- a/kamon-core/src/main/scala/kamon/metric/TickSnapshot.scala +++ b/kamon-core/src/main/scala/kamon/metric/PeriodSnapshot.scala @@ -16,15 +16,17 @@ package kamon package metric +import java.time.Instant + /** + * Contains immutable snapshots of all metrics recorded since from and until to. * - * @param interval + * @param from + * @param to * @param metrics */ -case class TickSnapshot(interval: Interval, metrics: MetricsSnapshot) - -case class Interval(from: Long, to: Long) +case class PeriodSnapshot(from: Instant, to: Instant, metrics: MetricsSnapshot) case class MetricsSnapshot( histograms: Seq[MetricDistribution], |