an Erlang client for statsd
Erlang
Switch branches/tags
Nothing to show
Pull request Compare This branch is 4 commits ahead, 10 commits behind domnikl:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
deps
ebin
src
.gitignore
Emakefile
README.md
rebar

README.md

statsd-erlang

an Erlang client for statsd that is based on OTP's gen_server behaviour.

Performance

Benchmarking locally I can do about 18773/s. Be-aware that you exceed this value it will cause your server to crash because the gen_server message queue will build up. We can round robin gen_servers to get better performance.

Benchmark

Fun = fun(Y, Fun, N) ->
  case N of 
   0 -> ok;
   _ -> Fun(), Y(Y, Fun, N - 1)
  end
end.

RepeatUntil = fun(Y, Fun) ->
  case Fun() of
   true -> ok;
   _ -> Y(Y, Fun)
   end
end.

timer:tc(fun() -> Fun(Fun, fun() -> statsd:increment("foo") end, 100000), RepeatUntil(RepeatUntil, fun() -> element(2, erlang:process_info(whereis(statsd), message_queue_len)) =:= 0 end) end).

Usage

Add statsd-erlang to your application file like this:

{mod, {statsd_app, []}}

You can specify the host and/or port in the configuration, too:

{mod, {statsd_app, ["localhost", 8125]}}

The values "localhost" and 8125 are set by default, so you only have to specify them if you want to use others.

statsd:start("localhost", 8125).

statsd:increment("foo.bar").
statsd:count("foo.bar", 5).
statsd:timing("foo.bar", 2500).

Development

To compile the source, run erl -make from the root directory. You can also use rebar.

Author

Original author: Dominik Liebler liebler.dominik@googlemail.com

License

(The MIT License)

Copyright (c) 2012 Dominik Liebler

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.