aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDiego <diegolparra@gmail.com>2014-05-02 22:14:23 -0300
committerDiego <diegolparra@gmail.com>2014-05-02 22:14:23 -0300
commit30df67da8c923a3d3f023fa5ed846212b0d9c822 (patch)
tree538625a913883af9460f513ae6b39c614800310d
parent3b418cf3f757704dbc979cd156084e2379fb5bec (diff)
downloadKamon-30df67da8c923a3d3f023fa5ed846212b0d9c822.tar.gz
Kamon-30df67da8c923a3d3f023fa5ed846212b0d9c822.tar.bz2
Kamon-30df67da8c923a3d3f023fa5ed846212b0d9c822.zip
+ statsd: added kamon counter instrument
-rw-r--r--kamon-core/src/main/scala/kamon/metrics/instruments/CounterRecorder.scala2
-rw-r--r--kamon-statsd/src/main/scala/kamon/statsd/StatsDMetricsSender.scala2
-rw-r--r--kamon-statsd/src/test/scala/kamon/statsd/StatsDMetricSenderSpec.scala15
3 files changed, 15 insertions, 4 deletions
diff --git a/kamon-core/src/main/scala/kamon/metrics/instruments/CounterRecorder.scala b/kamon-core/src/main/scala/kamon/metrics/instruments/CounterRecorder.scala
index 0fd56105..a87fa828 100644
--- a/kamon-core/src/main/scala/kamon/metrics/instruments/CounterRecorder.scala
+++ b/kamon-core/src/main/scala/kamon/metrics/instruments/CounterRecorder.scala
@@ -34,5 +34,5 @@ class CounterRecorder extends MetricRecorder {
}
object CounterRecorder {
- def apply() = new CounterRecorder
+ def apply():CounterRecorder = new CounterRecorder
} \ No newline at end of file
diff --git a/kamon-statsd/src/main/scala/kamon/statsd/StatsDMetricsSender.scala b/kamon-statsd/src/main/scala/kamon/statsd/StatsDMetricsSender.scala
index a3ad226a..470d6c23 100644
--- a/kamon-statsd/src/main/scala/kamon/statsd/StatsDMetricsSender.scala
+++ b/kamon-statsd/src/main/scala/kamon/statsd/StatsDMetricsSender.scala
@@ -69,7 +69,7 @@ class StatsDMetricsSender(remote: InetSocketAddress, maxPacketSizeInBytes: Long)
instrumentType match {
case Histogram ⇒ statsDMetricFormat(measurement.value.toString, "ms", (1D / measurement.count))
case Gauge ⇒ statsDMetricFormat(measurement.value.toString, "g")
- case Counter ⇒ "" // TODO: Need to decide how to report counters, when we have them!
+ case Counter ⇒ statsDMetricFormat(measurement.count.toString, "c")
}
}
}
diff --git a/kamon-statsd/src/test/scala/kamon/statsd/StatsDMetricSenderSpec.scala b/kamon-statsd/src/test/scala/kamon/statsd/StatsDMetricSenderSpec.scala
index 8a61d70e..e736a6a7 100644
--- a/kamon-statsd/src/test/scala/kamon/statsd/StatsDMetricSenderSpec.scala
+++ b/kamon-statsd/src/test/scala/kamon/statsd/StatsDMetricSenderSpec.scala
@@ -26,6 +26,7 @@ import kamon.metrics.Subscriptions.TickMetricSnapshot
import java.lang.management.ManagementFactory
import java.net.InetSocketAddress
import com.typesafe.config.ConfigFactory
+import kamon.metrics.instruments.CounterRecorder
class StatsDMetricSenderSpec extends TestKitBase with WordSpecLike with Matchers {
implicit lazy val system = ActorSystem("statsd-metric-sender-spec",
@@ -96,8 +97,12 @@ class StatsDMetricSenderSpec extends TestKitBase with WordSpecLike with Matchers
val firstTestMetricKey = buildMetricKey(firstTestMetricName)
val secondTestMetricName = "second-test-metric"
val secondTestMetricKey = buildMetricKey(secondTestMetricName)
+ val thirdTestMetricName = "third-test-metric"
+ val thirdTestMetricKey = buildMetricKey(thirdTestMetricName)
+
val firstTestRecorder = HdrRecorder(1000L, 2, Scale.Unit)
val secondTestRecorder = HdrRecorder(1000L, 2, Scale.Unit)
+ val thirdTestRecorder = CounterRecorder()
firstTestRecorder.record(10L)
firstTestRecorder.record(10L)
@@ -106,12 +111,18 @@ class StatsDMetricSenderSpec extends TestKitBase with WordSpecLike with Matchers
secondTestRecorder.record(20L)
secondTestRecorder.record(21L)
+ thirdTestRecorder.record(1L)
+ thirdTestRecorder.record(1L)
+ thirdTestRecorder.record(1L)
+ thirdTestRecorder.record(1L)
+
val udp = setup(Map(
firstTestMetricName -> firstTestRecorder.collect(),
- secondTestMetricName -> secondTestRecorder.collect()))
+ secondTestMetricName -> secondTestRecorder.collect(),
+ thirdTestMetricName -> thirdTestRecorder.collect()))
val Udp.Send(data, _, _) = udp.expectMsgType[Udp.Send]
- data.utf8String should be(s"$firstTestMetricKey:10|ms|@0.5:11|ms\n$secondTestMetricKey:20|ms:21|ms")
+ data.utf8String should be(s"$firstTestMetricKey:10|ms|@0.5:11|ms\n$secondTestMetricKey:20|ms:21|ms\n$thirdTestMetricKey:4|c")
}
}