aboutsummaryrefslogtreecommitdiff
path: root/kamon-core/src/legacy-test/scala/kamon/metric/MetricScaleDecoratorSpec.scala
diff options
context:
space:
mode:
authorIvan Topolnjak <ivantopo@gmail.com>2017-06-06 14:15:15 +0200
committerIvan Topolnjak <ivantopo@gmail.com>2017-06-06 14:15:15 +0200
commitc52f8eaca0d1ccc4c992cba039e35e099b5b478b (patch)
treef9e78e2f929627e7547bef39fdf6cbcd544cb8d8 /kamon-core/src/legacy-test/scala/kamon/metric/MetricScaleDecoratorSpec.scala
parent1f5d9876dedb715ae1c31203ea4f15ebf031612c (diff)
downloadKamon-c52f8eaca0d1ccc4c992cba039e35e099b5b478b.tar.gz
Kamon-c52f8eaca0d1ccc4c992cba039e35e099b5b478b.tar.bz2
Kamon-c52f8eaca0d1ccc4c992cba039e35e099b5b478b.zip
make it compile for Scala 2.11 and 2.12
Diffstat (limited to 'kamon-core/src/legacy-test/scala/kamon/metric/MetricScaleDecoratorSpec.scala')
-rw-r--r--kamon-core/src/legacy-test/scala/kamon/metric/MetricScaleDecoratorSpec.scala102
1 files changed, 0 insertions, 102 deletions
diff --git a/kamon-core/src/legacy-test/scala/kamon/metric/MetricScaleDecoratorSpec.scala b/kamon-core/src/legacy-test/scala/kamon/metric/MetricScaleDecoratorSpec.scala
deleted file mode 100644
index d3d0f4fb..00000000
--- a/kamon-core/src/legacy-test/scala/kamon/metric/MetricScaleDecoratorSpec.scala
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * =========================================================================================
- * Copyright © 2013-2015 the kamon project <http://kamon.io/>
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the
- * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
- * either express or implied. See the License for the specific language governing permissions
- * and limitations under the License.
- * =========================================================================================
- */
-
-package kamon.metric
-
-import kamon.Kamon
-import kamon.metric.SubscriptionsDispatcher.TickMetricSnapshot
-import kamon.metric.instrument.{InstrumentFactory, Memory, Time, UnitOfMeasurement}
-import kamon.testkit.BaseKamonSpec
-import kamon.util.MilliTimestamp
-import org.scalatest.OptionValues._
-
-class MetricScaleDecoratorSpec extends BaseKamonSpec("metrics-scale-decorator-spec") with SnapshotFixtures {
- "the MetricScaleDecorator" when {
- "receives a snapshot" which {
-
- val scaleDecorator = system.actorOf(MetricScaleDecorator.props(
- Some(Time.Milliseconds), Some(Memory.KiloBytes), testActor
- ))
- "is empty" should {
- "do nothing for empty snapshots" in {
- scaleDecorator ! emptySnapshot
- expectMsg(emptySnapshot)
- }
- }
- "is non empty" should {
- scaleDecorator ! nonEmptySnapshot
- val scaled = expectMsgType[TickMetricSnapshot]
- val snapshot = scaled.metrics(testEntity)
-
- "scale time metrics" in {
- snapshot.histogram("nano-time").value.max should be(10L +- 1L)
- snapshot.counter("micro-time").value.count should be(1000L)
- }
- "scale memory metrics" in {
- snapshot.histogram("byte-memory").value.max should be(1)
- snapshot.counter("kbyte-memory").value.count should be(100L)
- }
- "do nothing with unknown metrics" in {
- snapshot.histogram("unknown-histogram").value.max should be(1000L)
- snapshot.counter("unknown-counter").value.count should be(10L)
- }
- "not change from and to" in {
- scaled.from.millis should be(1000)
- scaled.to.millis should be(2000)
- }
- }
- }
- }
-}
-
-trait SnapshotFixtures {
- self: BaseKamonSpec ⇒
-
- class ScaleDecoratorTestMetrics(instrumentFactory: InstrumentFactory)
- extends GenericEntityRecorder(instrumentFactory) {
- val nanoTime = histogram("nano-time", Time.Nanoseconds)
- val microTime = counter("micro-time", Time.Microseconds)
- val byteMemory = histogram("byte-memory", Memory.Bytes)
- val kbyteMemory = counter("kbyte-memory", Memory.KiloBytes)
- val unknownHistogram = histogram("unknown-histogram", UnitOfMeasurement.Unknown)
- val unknownCounter = counter("unknown-counter", UnitOfMeasurement.Unknown)
- }
-
- object ScaleDecoratorTestMetrics extends EntityRecorderFactory[ScaleDecoratorTestMetrics] {
- override def category: String = "decorator-spec"
-
- override def createRecorder(instrumentFactory: InstrumentFactory): ScaleDecoratorTestMetrics =
- new ScaleDecoratorTestMetrics(instrumentFactory)
- }
-
- val testEntity = Entity("metrics-scale-decorator-spec", "decorator-spec")
- val recorder = Kamon.metrics.entity(ScaleDecoratorTestMetrics, "metrics-scale-decorator-spec")
-
- val emptySnapshot = TickMetricSnapshot(new MilliTimestamp(1000), new MilliTimestamp(2000), Map.empty)
-
- recorder.unknownCounter.increment(10)
- recorder.unknownHistogram.record(1000L)
- recorder.nanoTime.record(10000000L)
- recorder.microTime.increment(1000000L)
- recorder.byteMemory.record(1024L)
- recorder.kbyteMemory.increment(100L)
-
- val nonEmptySnapshot = TickMetricSnapshot(new MilliTimestamp(1000), new MilliTimestamp(2000), Map(
- (testEntity → recorder.collect(collectionContext))
- ))
-
-}
-