Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Added support for gauges

  • Loading branch information...
commit 931ed2ea50ae6fa6fcfa148047214fd44fa53f54 1 parent 3cce8a1
Ali Yakamercan authored

Showing 2 changed files with 11 additions and 3 deletions. Show diff stats Hide diff stats

  1. +3 0  README.md
  2. +8 3 src/statsderl.erl
3  README.md
Source Rendered
@@ -18,6 +18,9 @@
18 18 Timestamp = erlang:now(),
19 19 statsderl:timing_now("test.timing", Timestamp, 0.5).
20 20
  21 +#### Gauge
  22 + statsderl:gauge("test.gauge", 333, 1.0).
  23 +
21 24 ### Base Key
22 25
23 26 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:
11 src/statsderl.erl
@@ -15,7 +15,7 @@
15 15 %% ------------------------------------------------------------------
16 16
17 17 -export([start_link/0, increment/3, decrement/3, timing/3,
18   - timing_now/3]).
  18 + timing_now/3, gauge/3]).
19 19
20 20 %% ------------------------------------------------------------------
21 21 %% gen_server Function Exports
@@ -43,6 +43,9 @@ timing(Key, Value, SampleRate) ->
43 43 timing_now(Key, Timestamp, SampleRate) ->
44 44 timing(Key, now_diff_ms(Timestamp), SampleRate).
45 45
  46 +gauge(Key, Value, SampleRate) ->
  47 + send(gauge, Key, Value, SampleRate).
  48 +
46 49 %% ------------------------------------------------------------------
47 50 %% gen_server Function Definitions
48 51 %% ------------------------------------------------------------------
@@ -114,5 +117,7 @@ generate_packet(Method, Key, Value, SampleRate) ->
114 117 decrement ->
115 118 [Key, <<":-">>, BinValue, <<"|c">>, BinSampleRate];
116 119 timing ->
117   - [Key, <<":">>, BinValue, <<"|ms">>, BinSampleRate]
118   - end.
  120 + [Key, <<":">>, BinValue, <<"|ms">>, BinSampleRate];
  121 + gauge ->
  122 + [Key, <<":">>, BinValue, <<"|g">>, BinSampleRate]
  123 + end.

0 comments on commit 931ed2e

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