diff options
author | Ivan Topolnjak <ivantopo@gmail.com> | 2014-04-08 02:25:47 -0300 |
---|---|---|
committer | Ivan Topolnjak <ivantopo@gmail.com> | 2014-04-08 02:25:47 -0300 |
commit | d23360425cf41fd5d6a6ab6d6507d3e97bb536e1 (patch) | |
tree | 49059d70b59439a5e2a7d17cd9c7544523e8fc55 /kamon-statsd/src/test/scala/kamon | |
parent | a22e467a9b4131d978861b048a5402c9bf08e20b (diff) | |
download | Kamon-d23360425cf41fd5d6a6ab6d6507d3e97bb536e1.tar.gz Kamon-d23360425cf41fd5d6a6ab6d6507d3e97bb536e1.tar.bz2 Kamon-d23360425cf41fd5d6a6ab6d6507d3e97bb536e1.zip |
= statsd: correctly send multiple packets for a single metric
Diffstat (limited to 'kamon-statsd/src/test/scala/kamon')
-rw-r--r-- | kamon-statsd/src/test/scala/kamon/statsd/StatsDMetricSenderSpec.scala | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/kamon-statsd/src/test/scala/kamon/statsd/StatsDMetricSenderSpec.scala b/kamon-statsd/src/test/scala/kamon/statsd/StatsDMetricSenderSpec.scala index caeaee28..94af4645 100644 --- a/kamon-statsd/src/test/scala/kamon/statsd/StatsDMetricSenderSpec.scala +++ b/kamon-statsd/src/test/scala/kamon/statsd/StatsDMetricSenderSpec.scala @@ -25,6 +25,7 @@ import org.HdrHistogram.HdrRecorder import kamon.metrics.Subscriptions.TickMetricSnapshot import java.lang.management.ManagementFactory import com.typesafe.config.ConfigFactory +import kamon.Kamon class StatsDMetricSenderSpec extends TestKitBase with WordSpecLike with Matchers { @@ -76,6 +77,26 @@ class StatsDMetricSenderSpec extends TestKitBase with WordSpecLike with Matchers data.utf8String should be(s"$testMetricKey:10|ms|@0.5") } + "flush the packet when the max-packet-size is reached" in new UdpListenerFixture { + val testMetricName = "test-metric" + val testMetricKey = buildMetricKey(testMetricName) + val testRecorder = HdrRecorder(1000L, 3, Scale.Unit) + + var bytes = testMetricKey.length + var level = 0 + while(bytes <= Kamon(StatsD).maxPacketSize) { + level += 1 + testRecorder.record(level) + bytes += s":$level|ms".length + } + + val udp = setup(Map(testMetricName -> testRecorder.collect())) + udp.expectMsgType[Udp.Send] // let the first flush pass + val Udp.Send(data, _, _) = udp.expectMsgType[Udp.Send] + + data.utf8String should be(s"$testMetricKey:$level|ms") + } + "render multiple keys in the same packet using newline as separator" in new UdpListenerFixture { val firstTestMetricName = "first-test-metric" |