diff options
author | Ivan Topolnjak <ivantopo@gmail.com> | 2014-04-06 02:28:45 -0300 |
---|---|---|
committer | Ivan Topolnjak <ivantopo@gmail.com> | 2014-04-06 02:28:45 -0300 |
commit | 58b5438784219878880252e0b13be9a7ed7c74c0 (patch) | |
tree | d048a9c89e4b9efcb29dc4a3e9a93a631eda7ab1 /kamon-core/src/main/scala/kamon/metrics | |
parent | f7affbc379c26c8e92ece02256038a781c5d9d52 (diff) | |
download | Kamon-58b5438784219878880252e0b13be9a7ed7c74c0.tar.gz Kamon-58b5438784219878880252e0b13be9a7ed7c74c0.tar.bz2 Kamon-58b5438784219878880252e0b13be9a7ed7c74c0.zip |
! core: add the notion of instrument types to metric snapshots
Diffstat (limited to 'kamon-core/src/main/scala/kamon/metrics')
-rw-r--r-- | kamon-core/src/main/scala/kamon/metrics/Metrics.scala | 14 | ||||
-rw-r--r-- | kamon-core/src/main/scala/kamon/metrics/instruments/HdrRecorder.scala | 4 |
2 files changed, 14 insertions, 4 deletions
diff --git a/kamon-core/src/main/scala/kamon/metrics/Metrics.scala b/kamon-core/src/main/scala/kamon/metrics/Metrics.scala index b82f429f..f07bf38e 100644 --- a/kamon-core/src/main/scala/kamon/metrics/Metrics.scala +++ b/kamon-core/src/main/scala/kamon/metrics/Metrics.scala @@ -19,6 +19,7 @@ package kamon.metrics import annotation.tailrec import com.typesafe.config.Config import kamon.metrics.MetricSnapshot.Measurement +import kamon.metrics.InstrumentTypes.InstrumentType trait MetricGroupCategory { def name: String @@ -49,7 +50,15 @@ trait MetricRecorder { def collect(): MetricSnapshotLike } +object InstrumentTypes { + sealed trait InstrumentType + case object Histogram extends InstrumentType + case object Gauge extends InstrumentType + case object Counter extends InstrumentType +} + trait MetricSnapshotLike { + def instrumentType: InstrumentType def numberOfMeasurements: Long def scale: Scale def measurements: Vector[Measurement] @@ -92,11 +101,12 @@ trait MetricSnapshotLike { } val totalNrOfMeasurements = go(measurements, that.measurements, 0) - MetricSnapshot(totalNrOfMeasurements, scale, mergedMeasurements.result()) + MetricSnapshot(instrumentType, totalNrOfMeasurements, scale, mergedMeasurements.result()) } } -case class MetricSnapshot(numberOfMeasurements: Long, scale: Scale, measurements: Vector[MetricSnapshot.Measurement]) extends MetricSnapshotLike +case class MetricSnapshot(instrumentType: InstrumentType, numberOfMeasurements: Long, scale: Scale, + measurements: Vector[MetricSnapshot.Measurement]) extends MetricSnapshotLike object MetricSnapshot { case class Measurement(value: Long, count: Long) { diff --git a/kamon-core/src/main/scala/kamon/metrics/instruments/HdrRecorder.scala b/kamon-core/src/main/scala/kamon/metrics/instruments/HdrRecorder.scala index 28520030..ce4fd76d 100644 --- a/kamon-core/src/main/scala/kamon/metrics/instruments/HdrRecorder.scala +++ b/kamon-core/src/main/scala/kamon/metrics/instruments/HdrRecorder.scala @@ -18,7 +18,7 @@ package org.HdrHistogram import java.util.concurrent.atomic.AtomicLongFieldUpdater import scala.annotation.tailrec -import kamon.metrics.{ Scale, MetricSnapshot, MetricSnapshotLike, MetricRecorder } +import kamon.metrics._ /** * This implementation aims to be used for real time data collection where data snapshots are taken often over time. @@ -64,7 +64,7 @@ class HdrRecorder(highestTrackableValue: Long, significantValueDigits: Int, scal while (!tryUpdateTotalCount) {} - MetricSnapshot(nrOfRecordings, scale, entries.result()) + MetricSnapshot(InstrumentTypes.Histogram, nrOfRecordings, scale, entries.result()) } } |