From b5b766d6d6f9d341b0ddcfec64e9cb409d980319 Mon Sep 17 00:00:00 2001 From: Louis-Philippe Gauthier Date: Thu, 15 Dec 2016 14:17:20 -0500 Subject: [PATCH] Fix sampling --- .travis.yml | 3 ++- src/statsderl_protocol.erl | 2 +- test/statsderl_tests.erl | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index d8f3b92..710b330 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,8 +8,10 @@ cache: directories: - $HOME/.cache/rebar3 - $TRAVIS_BUILD_DIR/_build +dist: trusty env: - CC=gcc-5 +group: edge install: true language: erlang notifications: @@ -18,4 +20,3 @@ otp_release: - 19.1 - 18.3 script: "make travis" -sudo: false diff --git a/src/statsderl_protocol.erl b/src/statsderl_protocol.erl index 5561a63..a9b8863 100644 --- a/src/statsderl_protocol.erl +++ b/src/statsderl_protocol.erl @@ -27,7 +27,7 @@ encode({timing, Key, Value}) -> format_sample_rate(SampleRate) when SampleRate >= 1 -> <<>>; format_sample_rate(SampleRate) -> - [<<"|@">>, float_to_list(SampleRate, [{decimals, 3}])]. + [<<"|@">>, float_to_list(SampleRate, [compact, {decimals, 6}])]. format_value(Value) when is_integer(Value) -> integer_to_list(Value); diff --git a/test/statsderl_tests.erl b/test/statsderl_tests.erl index bfb454f..1c2481b 100644 --- a/test/statsderl_tests.erl +++ b/test/statsderl_tests.erl @@ -67,7 +67,7 @@ sampling_rate_subtest(Socket) -> meck:new(granderl, [passthrough, no_history]), meck:expect(granderl, uniform, fun (?MAX_UNSIGNED_INT_32) -> 1 end), statsderl:counter("test", 1, 0.1234), - assert_packet(Socket, <<"test:1|c|@0.123">>), + assert_packet(Socket, <<"test:1|c|@0.1234">>), meck:expect(granderl, uniform, fun (?MAX_UNSIGNED_INT_32) -> ?MAX_UNSIGNED_INT_32 end),