Browse files

don't do random stuff if samplerate = 1

  • Loading branch information...
1 parent 6f78233 commit faf1f95c0147b8534fb3cf711b37e5db71f3f436 @RJ RJ committed Oct 25, 2012
Showing with 12 additions and 5 deletions.
  1. +12 −5 src/statsderl.erl
View
17 src/statsderl.erl
@@ -89,16 +89,23 @@ code_change(_OldVsn, State, _Extra) ->
%% Internal Function Definitions
%% ------------------------------------------------------------------
+send(Method, Key, Value, 1) ->
+ send_packet(Method, Key, Value, 1);
+
+send(Method, Key, Value, 1.0) ->
+ send_packet(Method, Key, Value, 1.0);
+
send(Method, Key, Value, SampleRate) ->
maybe_seed(),
case random:uniform() =< SampleRate of
- true ->
- Packet = generate_packet(Method, Key, Value, SampleRate),
- gen_server:cast(?MODULE, {send, Packet});
- false ->
- ok
+ true -> send_packet(Method, Key, Value, SampleRate);
+ false -> ok
end.
+send_packet(Method, Key, Value, SampleRate) ->
+ Packet = generate_packet(Method, Key, Value, SampleRate),
+ gen_server:cast(?MODULE, {send, Packet}).
+
now_diff_ms(Timestamp) ->
timer:now_diff(os:timestamp(), Timestamp) div 1000.

0 comments on commit faf1f95

Please sign in to comment.