aboutsummaryrefslogtreecommitdiff
path: root/kamon-core-tests
diff options
context:
space:
mode:
authorIvan Topolnjak <ivantopo@gmail.com>2017-12-05 02:11:34 +0100
committerIvan Topolnjak <ivantopo@gmail.com>2017-12-05 02:11:34 +0100
commit6b196b2626f618e452a25e9437c944ff4138636c (patch)
tree8f9dc1691055512e959afd4d238d01c94a63da56 /kamon-core-tests
parentb330bc51e1969b1e2284b120a47283d3dd0d8977 (diff)
downloadKamon-6b196b2626f618e452a25e9437c944ff4138636c.tar.gz
Kamon-6b196b2626f618e452a25e9437c944ff4138636c.tar.bz2
Kamon-6b196b2626f618e452a25e9437c944ff4138636c.zip
rename MinMaxCounter to RangeSampler
Diffstat (limited to 'kamon-core-tests')
-rw-r--r--kamon-core-tests/src/test/scala/kamon/metric/MetricLookupSpec.scala20
-rw-r--r--kamon-core-tests/src/test/scala/kamon/metric/RangeSamplerSpec.scala (renamed from kamon-core-tests/src/test/scala/kamon/metric/MinMaxCounterSpec.scala)56
-rw-r--r--kamon-core-tests/src/test/scala/kamon/metric/RecorderRegistrySpec.scala58
-rw-r--r--kamon-core-tests/src/test/scala/kamon/metric/instrument/InstrumentFactorySpec.scala114
4 files changed, 38 insertions, 210 deletions
diff --git a/kamon-core-tests/src/test/scala/kamon/metric/MetricLookupSpec.scala b/kamon-core-tests/src/test/scala/kamon/metric/MetricLookupSpec.scala
index 4df2397b..f6c27b5b 100644
--- a/kamon-core-tests/src/test/scala/kamon/metric/MetricLookupSpec.scala
+++ b/kamon-core-tests/src/test/scala/kamon/metric/MetricLookupSpec.scala
@@ -42,10 +42,10 @@ class MetricLookupSpec extends WordSpec with Matchers {
gaugeOne shouldBe theSameInstanceAs(gaugeTwo)
}
- "always return the same min-max-counter metric" in {
- val minMaxCounterOne = Kamon.minMaxCounter("min-max-counter-lookup")
- val minMaxCounterTwo = Kamon.minMaxCounter("min-max-counter-lookup")
- minMaxCounterOne shouldBe theSameInstanceAs(minMaxCounterTwo)
+ "always return the same range sampler metric" in {
+ val rangeSamplerOne = Kamon.rangeSampler("range-sampler-lookup")
+ val rangeSamplerTwo = Kamon.rangeSampler("range-sampler-lookup")
+ rangeSamplerOne shouldBe theSameInstanceAs(rangeSamplerTwo)
}
}
@@ -77,13 +77,13 @@ class MetricLookupSpec extends WordSpec with Matchers {
gaugeOne shouldBe theSameInstanceAs(gaugeThree)
}
- "always return the same min-max-counter for a set of tags" in {
- val minMaxCounterOne = Kamon.minMaxCounter("min-max-counter-lookup").refine("tag" -> "value")
- val minMaxCounterTwo = Kamon.minMaxCounter("min-max-counter-lookup").refine("tag" -> "value")
- val minMaxCounterThree = Kamon.minMaxCounter("min-max-counter-lookup").refine(javaMap("tag", "value"))
+ "always return the same range-sampler for a set of tags" in {
+ val rangeSamplerOne = Kamon.rangeSampler("range-sampler-lookup").refine("tag" -> "value")
+ val rangeSamplerTwo = Kamon.rangeSampler("range-sampler-lookup").refine("tag" -> "value")
+ val rangeSamplerThree = Kamon.rangeSampler("range-sampler-lookup").refine(javaMap("tag", "value"))
- minMaxCounterOne shouldBe theSameInstanceAs(minMaxCounterTwo)
- minMaxCounterOne shouldBe theSameInstanceAs(minMaxCounterThree)
+ rangeSamplerOne shouldBe theSameInstanceAs(rangeSamplerTwo)
+ rangeSamplerOne shouldBe theSameInstanceAs(rangeSamplerThree)
}
}
}
diff --git a/kamon-core-tests/src/test/scala/kamon/metric/MinMaxCounterSpec.scala b/kamon-core-tests/src/test/scala/kamon/metric/RangeSamplerSpec.scala
index 0ad3c45c..3aaf57a4 100644
--- a/kamon-core-tests/src/test/scala/kamon/metric/MinMaxCounterSpec.scala
+++ b/kamon-core-tests/src/test/scala/kamon/metric/RangeSamplerSpec.scala
@@ -22,69 +22,69 @@ import org.scalatest.{Matchers, WordSpec}
case class TemporalBucket(value: Long, frequency: Long) extends Bucket
-class MinMaxCounterSpec extends WordSpec with Matchers {
+class RangeSamplerSpec extends WordSpec with Matchers {
- "a MinMaxCounter" should {
+ "a RangeSampler" should {
"track ascending tendencies" in {
- val mmCounter = buildMinMaxCounter("track-ascending")
- mmCounter.increment()
- mmCounter.increment(3)
- mmCounter.increment()
+ val rangeSampler = buildRangeSampler("track-ascending")
+ rangeSampler.increment()
+ rangeSampler.increment(3)
+ rangeSampler.increment()
- mmCounter.sample()
+ rangeSampler.sample()
- val snapshot = mmCounter.snapshot()
+ val snapshot = rangeSampler.snapshot()
snapshot.distribution.min should be(0)
snapshot.distribution.max should be(5)
}
"track descending tendencies" in {
- val mmCounter = buildMinMaxCounter("track-descending")
- mmCounter.increment(5)
- mmCounter.decrement()
- mmCounter.decrement(3)
- mmCounter.decrement()
+ val rangeSampler = buildRangeSampler("track-descending")
+ rangeSampler.increment(5)
+ rangeSampler.decrement()
+ rangeSampler.decrement(3)
+ rangeSampler.decrement()
- mmCounter.sample()
+ rangeSampler.sample()
- val snapshot = mmCounter.snapshot()
+ val snapshot = rangeSampler.snapshot()
snapshot.distribution.min should be(0)
snapshot.distribution.max should be(5)
}
"reset the min and max to the current value after taking a snapshot" in {
- val mmCounter = buildMinMaxCounter("reset-min-max-to-current")
+ val rangeSampler = buildRangeSampler("reset-range-sampler-to-current")
- mmCounter.increment(5)
- mmCounter.decrement(3)
- mmCounter.sample()
+ rangeSampler.increment(5)
+ rangeSampler.decrement(3)
+ rangeSampler.sample()
- val firstSnapshot = mmCounter.snapshot()
+ val firstSnapshot = rangeSampler.snapshot()
firstSnapshot.distribution.min should be(0)
firstSnapshot.distribution.max should be(5)
- mmCounter.sample()
+ rangeSampler.sample()
- val secondSnapshot = mmCounter.snapshot()
+ val secondSnapshot = rangeSampler.snapshot()
secondSnapshot.distribution.min should be(2)
secondSnapshot.distribution.max should be(2)
}
"report zero as the min and current values if the current value fell bellow zero" in {
- val mmCounter = buildMinMaxCounter("report-zero")
+ val rangeSampler = buildRangeSampler("report-zero")
- mmCounter.decrement(3)
+ rangeSampler.decrement(3)
- mmCounter.sample()
+ rangeSampler.sample()
- val snapshot = mmCounter.snapshot()
+ val snapshot = rangeSampler.snapshot()
snapshot.distribution.min should be(0)
snapshot.distribution.max should be(0)
}
}
- def buildMinMaxCounter(name: String, tags: Map[String, String] = Map.empty, unit: MeasurementUnit = MeasurementUnit.none): SimpleMinMaxCounter =
- new SimpleMinMaxCounter(name, tags, new AtomicHdrHistogram(name, tags, unit, dynamicRange = DynamicRange.Default), Duration.ofMillis(100))
+ def buildRangeSampler(name: String, tags: Map[String, String] = Map.empty, unit: MeasurementUnit = MeasurementUnit.none): SimpleRangeSampler =
+ new SimpleRangeSampler(name, tags, new AtomicHdrHistogram(name, tags, unit, dynamicRange = DynamicRange.Default), Duration.ofMillis(100))
} \ No newline at end of file
diff --git a/kamon-core-tests/src/test/scala/kamon/metric/RecorderRegistrySpec.scala b/kamon-core-tests/src/test/scala/kamon/metric/RecorderRegistrySpec.scala
deleted file mode 100644
index 1053aa5f..00000000
--- a/kamon-core-tests/src/test/scala/kamon/metric/RecorderRegistrySpec.scala
+++ /dev/null
@@ -1,58 +0,0 @@
-/* =========================================================================================
- * Copyright © 2013-2017 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 com.typesafe.config.ConfigFactory
-import org.scalatest.{Matchers, WordSpec}
-
-//class RecorderRegistrySpec extends WordSpec with Matchers {
-// private val testConfig = ConfigFactory.parseString(
-// """
-// |kamon.metric.filters {
-// | accept-unmatched = false
-// |
-// | my-category {
-// | includes = ["**"]
-// | excludes = ["excluded"]
-// | }
-// |}
-// """.stripMargin
-// )
-// private val recorderRegistry = new RecorderRegistryImpl(testConfig.withFallback(ConfigFactory.load()))
-//
-//
-// "the RecorderRegistry" should {
-// "create entity recorders as requested and always return the same instance for a given entity" in {
-// val myFirstEntityRecorder = recorderRegistry.getRecorder(Entity("my-entity", "my-category", Map.empty))
-// val mySecondEntityRecorder = recorderRegistry.getRecorder(Entity("my-entity", "my-category", Map.empty))
-// mySecondEntityRecorder shouldBe theSameInstanceAs(myFirstEntityRecorder)
-// }
-//
-// "properly advice regarding entity filtering read from configuration" in {
-// recorderRegistry.shouldTrack(Entity("my-entity", "my-category", Map.empty)) shouldBe true
-// recorderRegistry.shouldTrack(Entity("other-eny", "my-category", Map.empty)) shouldBe true
-// recorderRegistry.shouldTrack(Entity("excluded", "my-category", Map.empty)) shouldBe false
-// }
-//
-// "allow removing entities" in {
-// val myFirstEntityRecorder = recorderRegistry.getRecorder(Entity("my-entity", "my-category", Map.empty))
-// recorderRegistry.removeRecorder(Entity("my-entity", "my-category", Map.empty))
-//
-// val mySecondEntityRecorder = recorderRegistry.getRecorder(Entity("my-entity", "my-category", Map.empty))
-// mySecondEntityRecorder shouldNot be theSameInstanceAs(myFirstEntityRecorder)
-// }
-// }
-//}
diff --git a/kamon-core-tests/src/test/scala/kamon/metric/instrument/InstrumentFactorySpec.scala b/kamon-core-tests/src/test/scala/kamon/metric/instrument/InstrumentFactorySpec.scala
deleted file mode 100644
index 21fe2b4d..00000000
--- a/kamon-core-tests/src/test/scala/kamon/metric/instrument/InstrumentFactorySpec.scala
+++ /dev/null
@@ -1,114 +0,0 @@
-package kamon.metric.instrument
-
-//import java.time.Duration
-//
-//import com.typesafe.config.ConfigFactory
-//import kamon.metric.Entity
-//import org.scalatest.{Matchers, WordSpec}
-//
-//class InstrumentFactorySpec extends WordSpec with Matchers{
-// val testEntity = Entity("test", "test-category", Map.empty)
-// val customEntity = Entity("test", "custom-category", Map.empty)
-// val baseConfiguration = ConfigFactory.parseString(
-// """
-// |kamon.metric.instrument-factory {
-// | default-settings {
-// | histogram {
-// | lowest-discernible-value = 100
-// | highest-trackable-value = 5000
-// | significant-value-digits = 2
-// | }
-// |
-// | min-max-counter {
-// | lowest-discernible-value = 200
-// | highest-trackable-value = 6000
-// | significant-value-digits = 3
-// | sample-interval = 647 millis
-// | }
-// | }
-// |
-// | custom-settings {
-// |
-// | }
-// |}
-// """.stripMargin
-// )
-//
-//
-// "the metrics InstrumentFactory" should {
-// "create instruments using the default configuration settings" in {
-// val factory = InstrumentFactory.fromConfig(baseConfiguration)
-// val histogram = factory.buildHistogram(testEntity, "my-histogram")
-// val mmCounter = factory.buildMinMaxCounter(testEntity, "my-mm-counter")
-//
-// histogram.dynamicRange.lowestDiscernibleValue shouldBe(100)
-// histogram.dynamicRange.highestTrackableValue shouldBe(5000)
-// histogram.dynamicRange.significantValueDigits shouldBe(2)
-//
-// mmCounter.dynamicRange.lowestDiscernibleValue shouldBe(200)
-// mmCounter.dynamicRange.highestTrackableValue shouldBe(6000)
-// mmCounter.dynamicRange.significantValueDigits shouldBe(3)
-// mmCounter.sampleInterval shouldBe(Duration.ofMillis(647))
-// }
-//
-// "accept custom settings when building instruments" in {
-// val factory = InstrumentFactory.fromConfig(baseConfiguration)
-// val histogram = factory.buildHistogram(testEntity, "my-histogram", DynamicRange.Loose)
-// val mmCounter = factory.buildMinMaxCounter(testEntity, "my-mm-counter", DynamicRange.Fine, Duration.ofMillis(500))
-//
-// histogram.dynamicRange shouldBe(DynamicRange.Loose)
-//
-// mmCounter.dynamicRange shouldBe(DynamicRange.Fine)
-// mmCounter.sampleInterval shouldBe(Duration.ofMillis(500))
-// }
-//
-// "allow overriding any default and provided settings via the custom-settings configuration key" in {
-// val customConfig = ConfigFactory.parseString(
-// """
-// |kamon.metric.instrument-factory.custom-settings {
-// | custom-category {
-// | modified-histogram {
-// | lowest-discernible-value = 99
-// | highest-trackable-value = 999
-// | significant-value-digits = 4
-// | }
-// |
-// | modified-mm-counter {
-// | lowest-discernible-value = 784
-// | highest-trackable-value = 14785
-// | significant-value-digits = 1
-// | sample-interval = 3 seconds
-// | }
-// | }
-// |}
-// """.stripMargin
-// ).withFallback(baseConfiguration)
-//
-// val factory = InstrumentFactory.fromConfig(customConfig)
-// val defaultHistogram = factory.buildHistogram(customEntity, "default-histogram")
-// val modifiedHistogram = factory.buildHistogram(customEntity, "modified-histogram", DynamicRange.Loose)
-//
-// defaultHistogram.dynamicRange.lowestDiscernibleValue shouldBe(100)
-// defaultHistogram.dynamicRange.highestTrackableValue shouldBe(5000)
-// defaultHistogram.dynamicRange.significantValueDigits shouldBe(2)
-//
-// modifiedHistogram.dynamicRange.lowestDiscernibleValue shouldBe(99)
-// modifiedHistogram.dynamicRange.highestTrackableValue shouldBe(999)
-// modifiedHistogram.dynamicRange.significantValueDigits shouldBe(4)
-//
-//
-// val defaultMMCounter = factory.buildMinMaxCounter(customEntity, "default-mm-counter")
-// val modifiedMMCounter = factory.buildMinMaxCounter(customEntity, "modified-mm-counter", DynamicRange.Loose)
-//
-// defaultMMCounter.dynamicRange.lowestDiscernibleValue shouldBe(200)
-// defaultMMCounter.dynamicRange.highestTrackableValue shouldBe(6000)
-// defaultMMCounter.dynamicRange.significantValueDigits shouldBe(3)
-// defaultMMCounter.sampleInterval shouldBe(Duration.ofMillis(647))
-//
-// modifiedMMCounter.dynamicRange.lowestDiscernibleValue shouldBe(784)
-// modifiedMMCounter.dynamicRange.highestTrackableValue shouldBe(14785)
-// modifiedMMCounter.dynamicRange.significantValueDigits shouldBe(1)
-// modifiedMMCounter.sampleInterval shouldBe(Duration.ofSeconds(3))
-// }
-// }
-//}