Skip to content
Browse files

Added support for gauges

  • Loading branch information...
1 parent 3cce8a1 commit 931ed2ea50ae6fa6fcfa148047214fd44fa53f54 Ali Yakamercan committed May 10, 2012
Showing with 11 additions and 3 deletions.
  1. +3 −0 README.md
  2. +8 −3 src/statsderl.erl
View
3 README.md
@@ -18,6 +18,9 @@
Timestamp = erlang:now(),
statsderl:timing_now("test.timing", Timestamp, 0.5).
+#### Gauge
+ statsderl:gauge("test.gauge", 333, 1.0).
+
### Base Key
For multi-node setups, it might be useful to be able to define a basic key based on the current node name, for example. Statsderl supports doing so by setting the app variable `base_key` to some iolist:
View
11 src/statsderl.erl
@@ -15,7 +15,7 @@
%% ------------------------------------------------------------------
-export([start_link/0, increment/3, decrement/3, timing/3,
- timing_now/3]).
+ timing_now/3, gauge/3]).
%% ------------------------------------------------------------------
%% gen_server Function Exports
@@ -43,6 +43,9 @@ timing(Key, Value, SampleRate) ->
timing_now(Key, Timestamp, SampleRate) ->
timing(Key, now_diff_ms(Timestamp), SampleRate).
+gauge(Key, Value, SampleRate) ->
+ send(gauge, Key, Value, SampleRate).
+
%% ------------------------------------------------------------------
%% gen_server Function Definitions
%% ------------------------------------------------------------------
@@ -114,5 +117,7 @@ generate_packet(Method, Key, Value, SampleRate) ->
decrement ->
[Key, <<":-">>, BinValue, <<"|c">>, BinSampleRate];
timing ->
- [Key, <<":">>, BinValue, <<"|ms">>, BinSampleRate]
- end.
+ [Key, <<":">>, BinValue, <<"|ms">>, BinSampleRate];
+ gauge ->
+ [Key, <<":">>, BinValue, <<"|g">>, BinSampleRate]
+ end.

0 comments on commit 931ed2e

Please sign in to comment.
Something went wrong with that request. Please try again.