aboutsummaryrefslogtreecommitdiff
path: root/kamon-annotation
diff options
context:
space:
mode:
authorIvan Topolnjak <ivantopo@gmail.com>2015-03-05 23:39:44 +0100
committerIvan Topolnjak <ivantopo@gmail.com>2015-03-09 23:09:08 +0100
commit959ce3573253ec4ac5b837d8a9c9e70f1f80bd6b (patch)
tree27c1fe8f22429fe3820f988ab17caaf8e4a6fa3a /kamon-annotation
parent69ea63923e0d3697f8ca4c7eb9cb808821832aa2 (diff)
downloadKamon-959ce3573253ec4ac5b837d8a9c9e70f1f80bd6b.tar.gz
Kamon-959ce3573253ec4ac5b837d8a9c9e70f1f80bd6b.tar.bz2
Kamon-959ce3573253ec4ac5b837d8a9c9e70f1f80bd6b.zip
! all: introduced support for metric tags.
Diffstat (limited to 'kamon-annotation')
-rw-r--r--kamon-annotation/src/main/scala/kamon/annotation/instrumentation/BaseAnnotationInstrumentation.scala8
-rw-r--r--kamon-annotation/src/test/scala/kamon/annotation/AnnotationInstrumentationSpec.scala93
-rw-r--r--kamon-annotation/src/test/scala/kamon/annotation/StaticAnnotationInstrumentationJavaSpec.scala74
-rw-r--r--kamon-annotation/src/test/scala/kamon/annotation/StaticAnnotationInstrumentationSpec.scala92
4 files changed, 122 insertions, 145 deletions
diff --git a/kamon-annotation/src/main/scala/kamon/annotation/instrumentation/BaseAnnotationInstrumentation.scala b/kamon-annotation/src/main/scala/kamon/annotation/instrumentation/BaseAnnotationInstrumentation.scala
index 57e8c4d7..2074e237 100644
--- a/kamon-annotation/src/main/scala/kamon/annotation/instrumentation/BaseAnnotationInstrumentation.scala
+++ b/kamon-annotation/src/main/scala/kamon/annotation/instrumentation/BaseAnnotationInstrumentation.scala
@@ -39,7 +39,7 @@ class BaseAnnotationInstrumentation {
val time = method.getAnnotation(classOf[Time])
val name = evalString(time.name())
val tags = evalTags(time.tags())
- val currentHistogram = Kamon.simpleMetrics.histogram(HistogramKey(name, tags))
+ val currentHistogram = Kamon.metrics.histogram(name, tags)
histograms.set(jps.getId, currentHistogram)
currentHistogram
}
@@ -50,7 +50,7 @@ class BaseAnnotationInstrumentation {
val name = evalString(histogram.name())
val tags = evalTags(histogram.tags())
val dynamicRange = DynamicRange(histogram.lowestDiscernibleValue(), histogram.highestTrackableValue(), histogram.precision())
- val currentHistogram = Kamon.simpleMetrics.histogram(HistogramKey(name, tags), dynamicRange)
+ val currentHistogram = Kamon.metrics.histogram(name, tags, dynamicRange)
histograms.set(jps.getId, currentHistogram)
currentHistogram
}
@@ -60,7 +60,7 @@ class BaseAnnotationInstrumentation {
val minMaxCount = method.getAnnotation(classOf[MinMaxCount])
val name = evalString(minMaxCount.name())
val tags = evalTags(minMaxCount.tags())
- val minMaxCounter = Kamon.simpleMetrics.minMaxCounter(MinMaxCounterKey(name, tags))
+ val minMaxCounter = Kamon.metrics.minMaxCounter(name, tags)
minMaxCounters.set(jps.getId, minMaxCounter)
minMaxCounter
}
@@ -70,7 +70,7 @@ class BaseAnnotationInstrumentation {
val count = method.getAnnotation(classOf[Count])
val name = evalString(count.name())
val tags = evalTags(count.tags())
- val counter = Kamon.simpleMetrics.counter(CounterKey(name, tags))
+ val counter = Kamon.metrics.counter(name, tags)
counters.set(jps.getId, counter)
counter
}
diff --git a/kamon-annotation/src/test/scala/kamon/annotation/AnnotationInstrumentationSpec.scala b/kamon-annotation/src/test/scala/kamon/annotation/AnnotationInstrumentationSpec.scala
index 41f0fc34..3d94d246 100644
--- a/kamon-annotation/src/test/scala/kamon/annotation/AnnotationInstrumentationSpec.scala
+++ b/kamon-annotation/src/test/scala/kamon/annotation/AnnotationInstrumentationSpec.scala
@@ -19,10 +19,9 @@ package kamon.annotation
import com.typesafe.config.ConfigFactory
import kamon.metric._
import kamon.testkit.BaseKamonSpec
+import kamon.trace.SegmentCategory
class AnnotationInstrumentationSpec extends BaseKamonSpec("annotation-instrumentation-spec") {
- import kamon.metric.TraceMetricsSpec.SegmentSyntax
-
override lazy val config =
ConfigFactory.parseString(
"""
@@ -38,7 +37,6 @@ class AnnotationInstrumentationSpec extends BaseKamonSpec("annotation-instrument
val snapshot = takeSnapshotOf("trace", "trace")
snapshot.histogram("elapsed-time").get.numberOfMeasurements should be(10)
- snapshot.segments.size should be(0)
}
"create a segment when is invoked a method annotated with @Segment" in {
@@ -47,8 +45,13 @@ class AnnotationInstrumentationSpec extends BaseKamonSpec("annotation-instrument
val snapshot = takeSnapshotOf("trace-with-segment", "trace")
snapshot.histogram("elapsed-time").get.numberOfMeasurements should be(10)
- snapshot.segments.size should be(1)
- snapshot.segment("inner-segment", "inner", "segment") should not be empty
+ val segmentMetricsSnapshot = takeSnapshotOf("inner-segment", "trace-segment",
+ tags = Map(
+ "trace" -> "trace-with-segment",
+ "category" -> "inner",
+ "library" -> "segment"))
+
+ segmentMetricsSnapshot.histogram("elapsed-time").get.numberOfMeasurements should be(10)
}
"create a segment when is invoked a method annotated with @Segment and evaluate EL expressions" in {
@@ -57,28 +60,30 @@ class AnnotationInstrumentationSpec extends BaseKamonSpec("annotation-instrument
val snapshot = takeSnapshotOf("trace-with-segment-el", "trace")
snapshot.histogram("elapsed-time").get.numberOfMeasurements should be(10)
- snapshot.segments.size should be(10)
- snapshot.segment("inner-segment:1", "inner", "segment") should not be empty
+ val segmentMetricsSnapshot = takeSnapshotOf("inner-segment:1", "trace-segment",
+ tags = Map(
+ "trace" -> "trace-with-segment-el",
+ "category" -> "inner",
+ "library" -> "segment"))
+
+ segmentMetricsSnapshot.histogram("elapsed-time").get.numberOfMeasurements should be(1)
}
"count the invocations of a method annotated with @Count" in {
for (id ← 1 to 10) Annotated(id).count()
- val snapshot = takeSnapshotOf("simple-metric", "simple-metric")
- snapshot.counter("count").get.count should be(10)
+ val snapshot = takeSnapshotOf("count", "counter")
+ snapshot.counter("counter").get.count should be(10)
}
"count the invocations of a method annotated with @Count and evaluate EL expressions" in {
for (id ← 1 to 2) Annotated(id).countWithEL()
- val snapshot = takeSnapshotOf("simple-metric", "simple-metric")
- snapshot.counter("count:1").get.count should be(1)
- snapshot.counter("count:2").get.count should be(1)
+ val counter1Snapshot = takeSnapshotOf("count:1", "counter", Map("counter" -> "1", "env" -> "prod"))
+ counter1Snapshot.counter("counter").get.count should be(1)
- val counterKey = (name: String) ⇒ (key: CounterKey) ⇒ key.name == name
-
- snapshot.counters.keys.find(counterKey("count:1")).get.metadata should be(Map("counter" -> "1", "env" -> "prod"))
- snapshot.counters.keys.find(counterKey("count:2")).get.metadata should be(Map("counter" -> "1", "env" -> "prod"))
+ val counter2Snapshot = takeSnapshotOf("count:2", "counter", Map("counter" -> "1", "env" -> "prod"))
+ counter2Snapshot.counter("counter").get.count should be(1)
}
"count the current invocations of a method annotated with @MinMaxCount" in {
@@ -86,45 +91,38 @@ class AnnotationInstrumentationSpec extends BaseKamonSpec("annotation-instrument
Annotated(id).countMinMax()
}
- val snapshot = takeSnapshotOf("simple-metric", "simple-metric")
- snapshot.minMaxCounter("minMax").get.max should be(1)
+ val snapshot = takeSnapshotOf("minMax", "min-max-counter")
+ snapshot.minMaxCounter("min-max-counter").get.max should be(1)
}
"count the current invocations of a method annotated with @MinMaxCount and evaluate EL expressions" in {
for (id ← 1 to 10) Annotated(id).countMinMaxWithEL()
- val snapshot = takeSnapshotOf("simple-metric", "simple-metric")
- snapshot.minMaxCounter("minMax:1").get.sum should be(1)
- snapshot.minMaxCounter("minMax:2").get.sum should be(1)
-
- val minMaxKey = (name: String) ⇒ (key: MinMaxCounterKey) ⇒ key.name == name
+ val minMaxCounter1Snapshot = takeSnapshotOf("minMax:1", "min-max-counter", tags = Map("minMax" -> "1", "env" -> "dev"))
+ minMaxCounter1Snapshot.minMaxCounter("min-max-counter").get.sum should be(1)
- snapshot.minMaxCounters.keys.find(minMaxKey("minMax:1")).get.metadata should be(Map("minMax" -> "1", "env" -> "dev"))
- snapshot.minMaxCounters.keys.find(minMaxKey("minMax:2")).get.metadata should be(Map("minMax" -> "1", "env" -> "dev"))
+ val minMaxCounter2Snapshot = takeSnapshotOf("minMax:2", "min-max-counter", tags = Map("minMax" -> "1", "env" -> "dev"))
+ minMaxCounter2Snapshot.minMaxCounter("min-max-counter").get.sum should be(1)
}
"measure the time spent in the execution of a method annotated with @Time" in {
for (id ← 1 to 1) Annotated(id).time()
- val snapshot = takeSnapshotOf("simple-metric", "simple-metric")
- snapshot.histogram("time").get.numberOfMeasurements should be(1)
+ val snapshot = takeSnapshotOf("time", "histogram")
+ snapshot.histogram("histogram").get.numberOfMeasurements should be(1)
}
"measure the time spent in the execution of a method annotated with @Time and evaluate EL expressions" in {
for (id ← 1 to 1) Annotated(id).timeWithEL()
- val snapshot = takeSnapshotOf("simple-metric", "simple-metric")
- snapshot.histogram("time:1").get.numberOfMeasurements should be(1)
-
- val histogramKey = (name: String) ⇒ (key: HistogramKey) ⇒ key.name == name
-
- snapshot.histograms.keys.find(histogramKey("time:1")).get.metadata should be(Map("slow-service" -> "service", "env" -> "prod"))
+ val snapshot = takeSnapshotOf("time:1", "histogram", tags = Map("slow-service" -> "service", "env" -> "prod"))
+ snapshot.histogram("histogram").get.numberOfMeasurements should be(1)
}
"record the value returned by a method annotated with @Histogram" in {
for (value ← 1 to 5) Annotated().histogram(value)
- val snapshot = takeSnapshotOf("simple-metric", "simple-metric")
+ val snapshot = takeSnapshotOf("histogram", "histogram")
snapshot.histogram("histogram").get.numberOfMeasurements should be(5)
snapshot.histogram("histogram").get.min should be(1)
snapshot.histogram("histogram").get.max should be(5)
@@ -134,23 +132,18 @@ class AnnotationInstrumentationSpec extends BaseKamonSpec("annotation-instrument
"record the value returned by a method annotated with @Histogram and evaluate EL expressions" in {
for (value ← 1 to 2) Annotated(value).histogramWithEL(value)
- val snapshot = takeSnapshotOf("simple-metric", "simple-metric")
- snapshot.histogram("histogram:1").get.numberOfMeasurements should be(1)
- snapshot.histogram("histogram:1").get.min should be(1)
- snapshot.histogram("histogram:1").get.max should be(1)
- snapshot.histogram("histogram:1").get.sum should be(1)
-
- snapshot.histogram("histogram:2").get.numberOfMeasurements should be(1)
- snapshot.histogram("histogram:2").get.min should be(2)
- snapshot.histogram("histogram:2").get.max should be(2)
- snapshot.histogram("histogram:2").get.sum should be(2)
-
- val histogramKey = (name: String) ⇒ (key: HistogramKey) ⇒ key.name == name
-
- snapshot.histograms.keys.find(histogramKey("histogram:1")).get.metadata should be(Map("histogram" -> "hdr", "env" -> "prod"))
- snapshot.histograms.keys.find(histogramKey("histogram:2")).get.metadata should be(Map("histogram" -> "hdr", "env" -> "prod"))
+ val snapshot1 = takeSnapshotOf("histogram:1", "histogram", tags = Map("histogram" -> "hdr", "env" -> "prod"))
+ snapshot1.histogram("histogram").get.numberOfMeasurements should be(1)
+ snapshot1.histogram("histogram").get.min should be(1)
+ snapshot1.histogram("histogram").get.max should be(1)
+ snapshot1.histogram("histogram").get.sum should be(1)
+
+ val snapshot2 = takeSnapshotOf("histogram:2", "histogram", tags = Map("histogram" -> "hdr", "env" -> "prod"))
+ snapshot2.histogram("histogram").get.numberOfMeasurements should be(1)
+ snapshot2.histogram("histogram").get.min should be(2)
+ snapshot2.histogram("histogram").get.max should be(2)
+ snapshot2.histogram("histogram").get.sum should be(2)
}
-
}
}
diff --git a/kamon-annotation/src/test/scala/kamon/annotation/StaticAnnotationInstrumentationJavaSpec.scala b/kamon-annotation/src/test/scala/kamon/annotation/StaticAnnotationInstrumentationJavaSpec.scala
index 4bae9f1d..6e0fbd02 100644
--- a/kamon-annotation/src/test/scala/kamon/annotation/StaticAnnotationInstrumentationJavaSpec.scala
+++ b/kamon-annotation/src/test/scala/kamon/annotation/StaticAnnotationInstrumentationJavaSpec.scala
@@ -21,8 +21,6 @@ import kamon.metric.{ HistogramKey, MinMaxCounterKey, CounterKey }
import kamon.testkit.BaseKamonSpec
class StaticAnnotationInstrumentationJavaSpec extends BaseKamonSpec("static-annotation-instrumentation-java-spec") {
- import kamon.metric.TraceMetricsSpec.SegmentSyntax
-
override lazy val config =
ConfigFactory.parseString(
"""
@@ -38,16 +36,17 @@ class StaticAnnotationInstrumentationJavaSpec extends BaseKamonSpec("static-anno
val snapshot = takeSnapshotOf("trace", "trace")
snapshot.histogram("elapsed-time").get.numberOfMeasurements should be(10)
- snapshot.segments.size should be(0)
}
"create a segment when is invoked a static method annotated with @Segment" in {
- for (id ← 1 to 10) AnnotatedJavaClass.segment()
+ for (id ← 1 to 7) AnnotatedJavaClass.segment()
- val snapshot = takeSnapshotOf("trace-with-segment", "trace")
- snapshot.histogram("elapsed-time").get.numberOfMeasurements should be(10)
+ val segmentMetricsSnapshot = takeSnapshotOf("inner-segment", "trace-segment",
+ tags = Map(
+ "trace" -> "trace-with-segment",
+ "category" -> "inner",
+ "library" -> "segment"))
- snapshot.segments.size should be(1)
- snapshot.segment("inner-segment", "inner", "segment") should not be empty
+ segmentMetricsSnapshot.histogram("elapsed-time").get.numberOfMeasurements should be(7)
}
"create a segment when is invoked a static method annotated with @Segment and evaluate EL expressions" in {
@@ -56,26 +55,27 @@ class StaticAnnotationInstrumentationJavaSpec extends BaseKamonSpec("static-anno
val snapshot = takeSnapshotOf("trace-with-segment-el", "trace")
snapshot.histogram("elapsed-time").get.numberOfMeasurements should be(10)
- snapshot.segments.size should be(1)
- snapshot.segment("inner-segment:10", "segments", "segment") should not be empty
+ val segmentMetricsSnapshot = takeSnapshotOf("inner-segment:10", "trace-segment",
+ tags = Map(
+ "trace" -> "trace-with-segment-el",
+ "category" -> "segments",
+ "library" -> "segment"))
+
+ segmentMetricsSnapshot.histogram("elapsed-time").get.numberOfMeasurements should be(10)
}
"count the invocations of a static method annotated with @Count" in {
for (id ← 1 to 10) AnnotatedJavaClass.count()
- val snapshot = takeSnapshotOf("simple-metric", "simple-metric")
- snapshot.counter("count").get.count should be(10)
+ val snapshot = takeSnapshotOf("count", "counter")
+ snapshot.counter("counter").get.count should be(10)
}
"count the invocations of a static method annotated with @Count and evaluate EL expressions" in {
for (id ← 1 to 2) AnnotatedJavaClass.countWithEL()
- val snapshot = takeSnapshotOf("simple-metric", "simple-metric")
- snapshot.counter("count:10").get.count should be(2)
-
- val counterKey = (name: String) ⇒ (key: CounterKey) ⇒ key.name == name
-
- snapshot.counters.keys.find(counterKey("count:10")).get.metadata should be(Map("counter" -> "1", "env" -> "prod"))
+ val snapshot = takeSnapshotOf("count:10", "counter", tags = Map("counter" -> "1", "env" -> "prod"))
+ snapshot.counter("counter").get.count should be(2)
}
"count the current invocations of a static method annotated with @MinMaxCount" in {
@@ -83,43 +83,35 @@ class StaticAnnotationInstrumentationJavaSpec extends BaseKamonSpec("static-anno
AnnotatedJavaClass.countMinMax()
}
- val snapshot = takeSnapshotOf("simple-metric", "simple-metric")
- snapshot.minMaxCounter("minMax").get.max should be(1)
+ val snapshot = takeSnapshotOf("minMax", "min-max-counter")
+ snapshot.minMaxCounter("min-max-counter").get.max should be(1)
}
"count the current invocations of a static method annotated with @MinMaxCount and evaluate EL expressions" in {
for (id ← 1 to 10) AnnotatedJavaClass.countMinMaxWithEL()
- val snapshot = takeSnapshotOf("simple-metric", "simple-metric")
- snapshot.minMaxCounter("minMax:10").get.max should be(1)
-
- val minMaxKey = (name: String) ⇒ (key: MinMaxCounterKey) ⇒ key.name == name
-
- snapshot.minMaxCounters.keys.find(minMaxKey("minMax:10")).get.metadata should be(Map("minMax" -> "1", "env" -> "dev"))
+ val snapshot = takeSnapshotOf("minMax:10", "min-max-counter", tags = Map("minMax" -> "1", "env" -> "dev"))
+ snapshot.minMaxCounter("min-max-counter").get.max should be(1)
}
"measure the time spent in the execution of a static method annotated with @Time" in {
for (id ← 1 to 1) AnnotatedJavaClass.time()
- val snapshot = takeSnapshotOf("simple-metric", "simple-metric")
- snapshot.histogram("time").get.numberOfMeasurements should be(1)
+ val snapshot = takeSnapshotOf("time", "histogram")
+ snapshot.histogram("histogram").get.numberOfMeasurements should be(1)
}
"measure the time spent in the execution of a static method annotated with @Time and evaluate EL expressions" in {
for (id ← 1 to 1) AnnotatedJavaClass.timeWithEL()
- val snapshot = takeSnapshotOf("simple-metric", "simple-metric")
- snapshot.histogram("time:10").get.numberOfMeasurements should be(1)
-
- val histogramKey = (name: String) ⇒ (key: HistogramKey) ⇒ key.name == name
-
- snapshot.histograms.keys.find(histogramKey("time:10")).get.metadata should be(Map("slow-service" -> "service", "env" -> "prod"))
+ val snapshot = takeSnapshotOf("time:10", "histogram", tags = Map("slow-service" -> "service", "env" -> "prod"))
+ snapshot.histogram("histogram").get.numberOfMeasurements should be(1)
}
"record the value returned by a static method annotated with @Histogram" in {
for (value ← 1 to 5) AnnotatedJavaClass.histogram(value.toLong)
- val snapshot = takeSnapshotOf("simple-metric", "simple-metric")
+ val snapshot = takeSnapshotOf("histogram", "histogram")
snapshot.histogram("histogram").get.numberOfMeasurements should be(5)
snapshot.histogram("histogram").get.min should be(1)
snapshot.histogram("histogram").get.max should be(5)
@@ -129,14 +121,10 @@ class StaticAnnotationInstrumentationJavaSpec extends BaseKamonSpec("static-anno
"record the value returned by a static method annotated with @Histogram and evaluate EL expressions" in {
for (value ← 1 to 2) AnnotatedJavaClass.histogramWithEL(value.toLong)
- val snapshot = takeSnapshotOf("simple-metric", "simple-metric")
- snapshot.histogram("histogram:10").get.numberOfMeasurements should be(2)
- snapshot.histogram("histogram:10").get.min should be(1)
- snapshot.histogram("histogram:10").get.max should be(2)
-
- val histogramKey = (name: String) ⇒ (key: HistogramKey) ⇒ key.name == name
-
- snapshot.histograms.keys.find(histogramKey("histogram:10")).get.metadata should be(Map("histogram" -> "hdr", "env" -> "prod"))
+ val snapshot = takeSnapshotOf("histogram:10", "histogram", tags = Map("histogram" -> "hdr", "env" -> "prod"))
+ snapshot.histogram("histogram").get.numberOfMeasurements should be(2)
+ snapshot.histogram("histogram").get.min should be(1)
+ snapshot.histogram("histogram").get.max should be(2)
}
}
} \ No newline at end of file
diff --git a/kamon-annotation/src/test/scala/kamon/annotation/StaticAnnotationInstrumentationSpec.scala b/kamon-annotation/src/test/scala/kamon/annotation/StaticAnnotationInstrumentationSpec.scala
index aea83409..a8e68009 100644
--- a/kamon-annotation/src/test/scala/kamon/annotation/StaticAnnotationInstrumentationSpec.scala
+++ b/kamon-annotation/src/test/scala/kamon/annotation/StaticAnnotationInstrumentationSpec.scala
@@ -21,8 +21,6 @@ import kamon.metric.{ HistogramKey, MinMaxCounterKey, CounterKey }
import kamon.testkit.BaseKamonSpec
class StaticAnnotationInstrumentationSpec extends BaseKamonSpec("static-annotation-instrumentation-spec") {
- import kamon.metric.TraceMetricsSpec.SegmentSyntax
-
override lazy val config =
ConfigFactory.parseString(
"""
@@ -31,53 +29,62 @@ class StaticAnnotationInstrumentationSpec extends BaseKamonSpec("static-annotati
| default-collection-context-buffer-size = 100
|}
""".stripMargin)
-
"the Kamon Annotation module" should {
"create a new trace when is invoked a method annotated with @Trace in a Scala Object" in {
- for (id ← 1 to 10) AnnotatedObject.trace()
+ for (id ← 1 to 42) AnnotatedObject.trace()
val snapshot = takeSnapshotOf("trace", "trace")
- snapshot.histogram("elapsed-time").get.numberOfMeasurements should be(10)
- snapshot.segments.size should be(0)
+ snapshot.histogram("elapsed-time").get.numberOfMeasurements should be(42)
}
+
"create a segment when is invoked a method annotated with @Trace and @Segment in a Scala Object" in {
- for (id ← 1 to 10) AnnotatedObject.segment()
+ for (id ← 1 to 15) AnnotatedObject.segment()
- val snapshot = takeSnapshotOf("trace-with-segment", "trace")
- snapshot.histogram("elapsed-time").get.numberOfMeasurements should be(10)
+ val segmentMetricsSnapshot = takeSnapshotOf("segment", "trace-segment",
+ tags = Map(
+ "trace" -> "trace-with-segment",
+ "category" -> "segments",
+ "library" -> "segment"))
- snapshot.segments.size should be(2)
- snapshot.segment("segment", "segments", "segment") should not be empty
- snapshot.segment("inner-segment", "inner", "segment") should not be empty
+ segmentMetricsSnapshot.histogram("elapsed-time").get.numberOfMeasurements should be(15)
}
"create a segment when is invoked a method annotated with @Trace and @Segment and evaluate EL expressions in a Scala Object" in {
- for (id ← 1 to 10) AnnotatedObject.segmentWithEL()
+ for (id ← 1 to 18) AnnotatedObject.segmentWithEL()
val snapshot = takeSnapshotOf("trace-with-segment-el", "trace")
- snapshot.histogram("elapsed-time").get.numberOfMeasurements should be(10)
+ snapshot.histogram("elapsed-time").get.numberOfMeasurements should be(18)
+
+ val segment10Snapshot = takeSnapshotOf("segment:10", "trace-segment",
+ tags = Map(
+ "trace" -> "trace-with-segment-el",
+ "category" -> "segments",
+ "library" -> "segment"))
- snapshot.segments.size should be(2)
- snapshot.segment("segment:10", "segments", "segment") should not be empty
- snapshot.segment("inner-segment", "inner", "segment") should not be empty
+ segment10Snapshot.histogram("elapsed-time").get.numberOfMeasurements should be(18)
+
+ val innerSegmentSnapshot = takeSnapshotOf("inner-segment", "trace-segment",
+ tags = Map(
+ "trace" -> "trace-with-segment-el",
+ "category" -> "inner",
+ "library" -> "segment"))
+
+ innerSegmentSnapshot.histogram("elapsed-time").get.numberOfMeasurements should be(18)
}
"count the invocations of a method annotated with @Count in a Scala Object" in {
for (id ← 1 to 10) AnnotatedObject.count()
- val snapshot = takeSnapshotOf("simple-metric", "simple-metric")
- snapshot.counter("count").get.count should be(10)
+ val snapshot = takeSnapshotOf("count", "counter")
+ snapshot.counter("counter").get.count should be(10)
}
"count the invocations of a method annotated with @Count and evaluate EL expressions in a Scala Object" in {
for (id ← 1 to 2) AnnotatedObject.countWithEL()
- val snapshot = takeSnapshotOf("simple-metric", "simple-metric")
- snapshot.counter("count:10").get.count should be(2)
-
- val counterKey = (name: String) ⇒ (key: CounterKey) ⇒ key.name == name
+ val snapshot = takeSnapshotOf("count:10", "counter", tags = Map("counter" -> "1", "env" -> "prod"))
+ snapshot.counter("counter").get.count should be(2)
- snapshot.counters.keys.find(counterKey("count:10")).get.metadata should be(Map("counter" -> "1", "env" -> "prod"))
}
"count the current invocations of a method annotated with @MinMaxCount in a Scala Object" in {
@@ -85,43 +92,36 @@ class StaticAnnotationInstrumentationSpec extends BaseKamonSpec("static-annotati
AnnotatedObject.countMinMax()
}
- val snapshot = takeSnapshotOf("simple-metric", "simple-metric")
- snapshot.minMaxCounter("minMax").get.max should be(1)
+ val snapshot = takeSnapshotOf("minMax", "min-max-counter")
+ snapshot.minMaxCounter("min-max-counter").get.max should be(1)
}
"count the current invocations of a method annotated with @MinMaxCount and evaluate EL expressions in a Scala Object" in {
for (id ← 1 to 10) AnnotatedObject.countMinMaxWithEL()
- val snapshot = takeSnapshotOf("simple-metric", "simple-metric")
- snapshot.minMaxCounter("minMax:10").get.max should be(1)
+ val snapshot = takeSnapshotOf("minMax:10", "min-max-counter", tags = Map("minMax" -> "1", "env" -> "dev"))
+ snapshot.minMaxCounter("min-max-counter").get.max should be(1)
- val minMaxKey = (name: String) ⇒ (key: MinMaxCounterKey) ⇒ key.name == name
-
- snapshot.minMaxCounters.keys.find(minMaxKey("minMax:10")).get.metadata should be(Map("minMax" -> "1", "env" -> "dev"))
}
"measure the time spent in the execution of a method annotated with @Time in a Scala Object" in {
for (id ← 1 to 1) AnnotatedObject.time()
- val snapshot = takeSnapshotOf("simple-metric", "simple-metric")
- snapshot.histogram("time").get.numberOfMeasurements should be(1)
+ val snapshot = takeSnapshotOf("time", "histogram")
+ snapshot.histogram("histogram").get.numberOfMeasurements should be(1)
}
"measure the time spent in the execution of a method annotated with @Time and evaluate EL expressions in a Scala Object" in {
for (id ← 1 to 1) AnnotatedObject.timeWithEL()
- val snapshot = takeSnapshotOf("simple-metric", "simple-metric")
- snapshot.histogram("time:10").get.numberOfMeasurements should be(1)
-
- val histogramKey = (name: String) ⇒ (key: HistogramKey) ⇒ key.name == name
-
- snapshot.histograms.keys.find(histogramKey("time:10")).get.metadata should be(Map("slow-service" -> "service", "env" -> "prod"))
+ val snapshot = takeSnapshotOf("time:10", "histogram", tags = Map("slow-service" -> "service", "env" -> "prod"))
+ snapshot.histogram("histogram").get.numberOfMeasurements should be(1)
}
"record the value returned by a method annotated with @Histogram in a Scala Object" in {
for (value ← 1 to 5) AnnotatedObject.histogram(value)
- val snapshot = takeSnapshotOf("simple-metric", "simple-metric")
+ val snapshot = takeSnapshotOf("histogram", "histogram")
snapshot.histogram("histogram").get.numberOfMeasurements should be(5)
snapshot.histogram("histogram").get.min should be(1)
snapshot.histogram("histogram").get.max should be(5)
@@ -131,14 +131,10 @@ class StaticAnnotationInstrumentationSpec extends BaseKamonSpec("static-annotati
"record the value returned by a method annotated with @Histogram and evaluate EL expressions in a Scala Object" in {
for (value ← 1 to 2) AnnotatedObject.histogramWithEL(value)
- val snapshot = takeSnapshotOf("simple-metric", "simple-metric")
- snapshot.histogram("histogram:10").get.numberOfMeasurements should be(2)
- snapshot.histogram("histogram:10").get.min should be(1)
- snapshot.histogram("histogram:10").get.max should be(2)
-
- val histogramKey = (name: String) ⇒ (key: HistogramKey) ⇒ key.name == name
-
- snapshot.histograms.keys.find(histogramKey("histogram:10")).get.metadata should be(Map("histogram" -> "hdr", "env" -> "prod"))
+ val snapshot = takeSnapshotOf("histogram:10", "histogram", tags = Map("histogram" -> "hdr", "env" -> "prod"))
+ snapshot.histogram("histogram").get.numberOfMeasurements should be(2)
+ snapshot.histogram("histogram").get.min should be(1)
+ snapshot.histogram("histogram").get.max should be(2)
}
}
}