Skip to content

Commit

Permalink
round non-ints to timing fun
Browse files Browse the repository at this point in the history
  • Loading branch information
RJ committed May 23, 2011
1 parent 733f78f commit e9e390b
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/estatsd.erl
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,19 @@

-define(SERVER, estatsd_server).

% Convenience: just give it the now() tuple when the work started
timing(Key, StartTime = {_,_,_}) ->
Dur = erlang:round(timer:now_diff(erlang:now(), StartTime)/1000),
timing(Key,Dur);

% Log timing information, ms
timing(Key, Duration) when is_integer(Duration) ->
gen_server:cast(?SERVER, {timing, Key, Duration});

% Convenience: just give it the now() tuple when the work started
timing(Key, StartTime = {_,_,_}) ->
Dur = erlang:round(timer:now_diff(erlang:now(), StartTime)/1000),
timing(Key,Dur).
timing(Key, Duration) ->
gen_server:cast(?SERVER, {timing, Key, erlang:round(Duration)}).




% Increments one or more stats counters
Expand Down

0 comments on commit e9e390b

Please sign in to comment.