aboutsummaryrefslogtreecommitdiff
path: root/kamon-core/src/main/scala/kamon/metric/instrument/Counter.scala
diff options
context:
space:
mode:
authorEugene Platonov <jozic@live.com>2015-12-01 13:26:50 -0500
committerEugene Platonov <jozic@live.com>2015-12-01 14:15:06 -0500
commit4a918ce6570129d3d4fd2d3e98d43f8078bb2d99 (patch)
tree9885a814379a7cc918607c7aa75ab8f8a3f8e6c5 /kamon-core/src/main/scala/kamon/metric/instrument/Counter.scala
parentdb5d0293dac1715bf585af42c0b86e668eba6803 (diff)
downloadKamon-4a918ce6570129d3d4fd2d3e98d43f8078bb2d99.tar.gz
Kamon-4a918ce6570129d3d4fd2d3e98d43f8078bb2d99.tar.bz2
Kamon-4a918ce6570129d3d4fd2d3e98d43f8078bb2d99.zip
+ core: provide generic way to scale time and memory metrics
Diffstat (limited to 'kamon-core/src/main/scala/kamon/metric/instrument/Counter.scala')
-rw-r--r--kamon-core/src/main/scala/kamon/metric/instrument/Counter.scala5
1 files changed, 5 insertions, 0 deletions
diff --git a/kamon-core/src/main/scala/kamon/metric/instrument/Counter.scala b/kamon-core/src/main/scala/kamon/metric/instrument/Counter.scala
index c1b69cbe..349a12bd 100644
--- a/kamon-core/src/main/scala/kamon/metric/instrument/Counter.scala
+++ b/kamon-core/src/main/scala/kamon/metric/instrument/Counter.scala
@@ -33,6 +33,7 @@ object Counter {
trait Snapshot extends InstrumentSnapshot {
def count: Long
def merge(that: InstrumentSnapshot, context: CollectionContext): Counter.Snapshot
+ def scale(from: UnitOfMeasurement, to: UnitOfMeasurement): Counter.Snapshot
}
}
@@ -57,4 +58,8 @@ case class CounterSnapshot(count: Long) extends Counter.Snapshot {
case CounterSnapshot(thatCount) ⇒ CounterSnapshot(count + thatCount)
case other ⇒ sys.error(s"Cannot merge a CounterSnapshot with the incompatible [${other.getClass.getName}] type.")
}
+
+ override def scale(from: UnitOfMeasurement, to: UnitOfMeasurement): Counter.Snapshot =
+ CounterSnapshot(from.tryScale(to)(count).toLong)
+
} \ No newline at end of file