From aa93757d615d805a9b6c30541055601b0df22951 Mon Sep 17 00:00:00 2001 From: Ivan Topolnjak Date: Mon, 14 Mar 2016 21:59:02 +0100 Subject: introduce selective instrumentation for akka actors. --- kamon-core/src/main/scala/kamon/util/Timestamp.scala | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'kamon-core/src/main/scala/kamon/util/Timestamp.scala') diff --git a/kamon-core/src/main/scala/kamon/util/Timestamp.scala b/kamon-core/src/main/scala/kamon/util/Timestamp.scala index eadc6690..5a192304 100644 --- a/kamon-core/src/main/scala/kamon/util/Timestamp.scala +++ b/kamon-core/src/main/scala/kamon/util/Timestamp.scala @@ -59,6 +59,8 @@ object MilliTimestamp { * timestamp in nanoseconds. */ class NanoTimestamp(val nanos: Long) extends AnyVal { + def -(that: NanoTimestamp) = new NanoTimestamp(nanos - that.nanos) + def +(that: NanoTimestamp) = new NanoTimestamp(nanos + that.nanos) override def toString: String = String.valueOf(nanos) + ".nanos" } @@ -70,6 +72,8 @@ object NanoTimestamp { * Number of nanoseconds between a arbitrary origin timestamp provided by the JVM via System.nanoTime() */ class RelativeNanoTimestamp(val nanos: Long) extends AnyVal { + def -(that: RelativeNanoTimestamp) = new RelativeNanoTimestamp(nanos - that.nanos) + def +(that: RelativeNanoTimestamp) = new RelativeNanoTimestamp(nanos + that.nanos) override def toString: String = String.valueOf(nanos) + ".nanos" def toMilliTimestamp: MilliTimestamp = @@ -77,6 +81,8 @@ class RelativeNanoTimestamp(val nanos: Long) extends AnyVal { } object RelativeNanoTimestamp { + val zero = new RelativeNanoTimestamp(0L) + def now: RelativeNanoTimestamp = new RelativeNanoTimestamp(System.nanoTime()) def relativeTo(milliTimestamp: MilliTimestamp): RelativeNanoTimestamp = new RelativeNanoTimestamp(now.nanos - (MilliTimestamp.now.millis - milliTimestamp.millis) * 1000000) -- cgit v1.2.3