diff options
Diffstat (limited to 'kamon-core/src/main')
-rw-r--r-- | kamon-core/src/main/scala/kamon/metric/Scaler.scala | 12 | ||||
-rw-r--r-- | kamon-core/src/main/scala/kamon/metric/TickSnapshot.scala | 23 |
2 files changed, 10 insertions, 25 deletions
diff --git a/kamon-core/src/main/scala/kamon/metric/Scaler.scala b/kamon-core/src/main/scala/kamon/metric/Scaler.scala index 21270e4c..6a98e256 100644 --- a/kamon-core/src/main/scala/kamon/metric/Scaler.scala +++ b/kamon-core/src/main/scala/kamon/metric/Scaler.scala @@ -25,7 +25,7 @@ class Scaler(targetTimeUnit: MeasurementUnit, targetInformationUnit: Measurement val scaleHistogram = new AtomicHdrHistogram("scaler", Map.empty, MeasurementUnit.none, dynamicRange) def scaleDistribution(metric: MetricDistribution): MetricDistribution = { - metric.measurementUnit match { + metric.unit match { case MeasurementUnit(Dimension.Time, magnitude) if(magnitude != targetTimeUnit.magnitude) => scaleMetricDistributionToTarget(metric, targetTimeUnit) @@ -37,7 +37,7 @@ class Scaler(targetTimeUnit: MeasurementUnit, targetInformationUnit: Measurement } def scaleMetricValue(metric: MetricValue): MetricValue = { - metric.measurementUnit match { + metric.unit match { case MeasurementUnit(Dimension.Time, magnitude) if(magnitude != targetTimeUnit.magnitude) => scaleMetricValueToTarget(metric, targetTimeUnit) @@ -50,24 +50,24 @@ class Scaler(targetTimeUnit: MeasurementUnit, targetInformationUnit: Measurement private def scaleMetricDistributionToTarget(metric: MetricDistribution, targetUnit: MeasurementUnit): MetricDistribution = { metric.distribution.bucketsIterator.foreach(b => { - val scaledValue = MeasurementUnit.scale(b.value, metric.measurementUnit, targetUnit) + val scaledValue = MeasurementUnit.scale(b.value, metric.unit, targetUnit) scaleHistogram.record(Math.ceil(scaledValue).toLong, b.frequency) }) scaleHistogram.snapshot(resetState = true).copy( name = metric.name, tags = metric.tags, - measurementUnit = targetUnit, + unit = targetUnit, dynamicRange = dynamicRange ) } private def scaleMetricValueToTarget(metric: MetricValue, targetUnit: MeasurementUnit): MetricValue = { - val scaledValue = MeasurementUnit.scale(metric.value, metric.measurementUnit, targetUnit) + val scaledValue = MeasurementUnit.scale(metric.value, metric.unit, targetUnit) metric.copy( value = Math.ceil(scaledValue).toLong, - measurementUnit = targetUnit + unit = targetUnit ) } } diff --git a/kamon-core/src/main/scala/kamon/metric/TickSnapshot.scala b/kamon-core/src/main/scala/kamon/metric/TickSnapshot.scala index 68b14223..32e88764 100644 --- a/kamon-core/src/main/scala/kamon/metric/TickSnapshot.scala +++ b/kamon-core/src/main/scala/kamon/metric/TickSnapshot.scala @@ -13,7 +13,8 @@ * ========================================================================================= */ -package kamon.metric +package kamon +package metric import kamon.util.MeasurementUnit @@ -38,14 +39,13 @@ case class MetricsSnapshot( * Snapshot for instruments that internally track a single value. Meant to be used for counters and gauges. * */ -case class MetricValue(name: String, tags: Map[String, String], measurementUnit: MeasurementUnit, value: Long) +case class MetricValue(name: String, tags: Tags, unit: MeasurementUnit, value: Long) /** * Snapshot for instruments that internally the distribution of values in a defined dynamic range. Meant to be used * with histograms and min max counters. */ -case class MetricDistribution(name: String, tags: Map[String, String], measurementUnit: MeasurementUnit, - dynamicRange: DynamicRange, distribution: Distribution) +case class MetricDistribution(name: String, tags: Tags, unit: MeasurementUnit, dynamicRange: DynamicRange, distribution: Distribution) trait Distribution { @@ -73,18 +73,3 @@ trait Percentile { def countUnderQuantile: Long } -// -//trait DistributionSnapshotInstrument { -// private[kamon] def snapshot(resetState: Boolean): MetricDistribution -//} -// -//trait SingleValueSnapshotInstrument { -// private[kamon] def snapshot(resetState: Boolean): MetricValue -//} -// -//trait SnapshotableHistogram extends Histogram with DistributionSnapshotInstrument -//trait SnapshotableMinMaxCounter extends MinMaxCounter with DistributionSnapshotInstrument -//trait SnapshotableCounter extends Counter with SingleValueSnapshotInstrument -//trait SnapshotableGauge extends Gauge with SingleValueSnapshotInstrument - - |