diff options
author | Ivan Topolnak <itopolnak@despegar.com> | 2014-04-08 13:06:25 -0300 |
---|---|---|
committer | Ivan Topolnak <itopolnak@despegar.com> | 2014-04-08 13:06:25 -0300 |
commit | 9b156f85943f96accb5b24bd54bb098cc452f7c9 (patch) | |
tree | 5be57fffbabf61de8c5ade6430409de39b23f1fe /kamon-statsd/src/main/scala/kamon | |
parent | 1e62e9b64bb1d754724294159934fa5491d145e5 (diff) | |
download | Kamon-9b156f85943f96accb5b24bd54bb098cc452f7c9.tar.gz Kamon-9b156f85943f96accb5b24bd54bb098cc452f7c9.tar.bz2 Kamon-9b156f85943f96accb5b24bd54bb098cc452f7c9.zip |
= statsd: avoid using scientific notation when rendering sampling rates
Diffstat (limited to 'kamon-statsd/src/main/scala/kamon')
-rw-r--r-- | kamon-statsd/src/main/scala/kamon/statsd/StatsDMetricsSender.scala | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/kamon-statsd/src/main/scala/kamon/statsd/StatsDMetricsSender.scala b/kamon-statsd/src/main/scala/kamon/statsd/StatsDMetricsSender.scala index 60404d7e..0520b621 100644 --- a/kamon-statsd/src/main/scala/kamon/statsd/StatsDMetricsSender.scala +++ b/kamon-statsd/src/main/scala/kamon/statsd/StatsDMetricsSender.scala @@ -24,6 +24,7 @@ import kamon.Kamon import kamon.metrics.Subscriptions.TickMetricSnapshot import kamon.metrics.MetricSnapshot.Measurement import kamon.metrics.InstrumentTypes.{ Counter, Gauge, Histogram, InstrumentType } +import java.text.DecimalFormat class StatsDMetricsSender extends Actor with UdpExtensionProvider { import context.system @@ -31,6 +32,8 @@ class StatsDMetricsSender extends Actor with UdpExtensionProvider { val statsDExtension = Kamon(StatsD) val remote = new InetSocketAddress(statsDExtension.hostname, statsDExtension.port) val metricKeyGenerator = new SimpleMetricKeyGenerator(context.system.settings.config) + val samplingRateFormat = new DecimalFormat() + samplingRateFormat.setMaximumFractionDigits(128) // Absurdly high, let the other end loss precision if it needs to. udpExtension ! Udp.SimpleSender @@ -64,7 +67,7 @@ class StatsDMetricsSender extends Actor with UdpExtensionProvider { def encodeMeasurement(measurement: Measurement, instrumentType: InstrumentType): ByteString = { def statsDMetricFormat(value: String, metricType: String, samplingRate: Double = 1D): ByteString = - ByteString(value + "|" + metricType + (if (samplingRate != 1D) "|@" + samplingRate else "")) + ByteString(value + "|" + metricType + (if (samplingRate != 1D) "|@" + samplingRateFormat.format(samplingRate) else "")) instrumentType match { case Histogram ⇒ statsDMetricFormat(measurement.value.toString, "ms", (1D / measurement.count)) |