aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Topolnjak <ivantopo@gmail.com>2017-12-12 00:33:36 +0100
committerIvan Topolnjak <ivantopo@gmail.com>2017-12-12 00:33:36 +0100
commit1860d08fdc3fde314e18c74f745c2861178388a7 (patch)
tree53c74cc86f0bc7d70e2e0db4c05dfd2123416560
parenta302c285f7950e1125094fe69a892afa574ea90b (diff)
downloadKamon-1860d08fdc3fde314e18c74f745c2861178388a7.tar.gz
Kamon-1860d08fdc3fde314e18c74f745c2861178388a7.tar.bz2
Kamon-1860d08fdc3fde314e18c74f745c2861178388a7.zip
rename TickSnapshot to PeriodSnapshot, use Instant instead of plain Longs
-rw-r--r--kamon-core/src/main/scala/kamon/ReporterRegistry.scala17
-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],