From b32f871adec935090f54c56418e97d175243d0de Mon Sep 17 00:00:00 2001 From: Ivan Topolnjak Date: Fri, 5 Dec 2014 02:22:25 +0100 Subject: + newrelic: react correctly to restart and shutdown events from the New Relic collector. --- kamon-core/src/main/scala/kamon/TimeUnits.scala | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'kamon-core/src/main/scala/kamon/TimeUnits.scala') diff --git a/kamon-core/src/main/scala/kamon/TimeUnits.scala b/kamon-core/src/main/scala/kamon/TimeUnits.scala index 44f5b4c3..f2933a11 100644 --- a/kamon-core/src/main/scala/kamon/TimeUnits.scala +++ b/kamon-core/src/main/scala/kamon/TimeUnits.scala @@ -1,10 +1,30 @@ package kamon +/** + * Epoch time stamp in seconds. + */ +class Timestamp(val seconds: Long) extends AnyVal { + def <(that: Timestamp): Boolean = this.seconds < that.seconds + def >(that: Timestamp): Boolean = this.seconds > that.seconds + def ==(that: Timestamp): Boolean = this.seconds == that.seconds + def >=(that: Timestamp): Boolean = this.seconds >= that.seconds + def <=(that: Timestamp): Boolean = this.seconds <= that.seconds + + override def toString: String = String.valueOf(seconds) + ".seconds" +} + +object Timestamp { + def now: Timestamp = new Timestamp(System.currentTimeMillis() / 1000) + def earlier(l: Timestamp, r: Timestamp): Timestamp = if (l <= r) l else r + def later(l: Timestamp, r: Timestamp): Timestamp = if (l >= r) l else r +} + /** * Epoch time stamp in milliseconds. */ class MilliTimestamp(val millis: Long) extends AnyVal { override def toString: String = String.valueOf(millis) + ".millis" + def toTimestamp: Timestamp = new Timestamp(millis / 1000) } object MilliTimestamp { -- cgit v1.2.3