aboutsummaryrefslogtreecommitdiff
path: root/kamon-core-tests/src/test/scala/kamon/metric/instrument/InstrumentFactorySpec.scala
blob: 21fe2b4d8609dda5bab69d2ca36cb22701684b09 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
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))
//    }
//  }
//}