Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
(Abandoned) Batched Erlang StatsD Client
Erlang Shell
Branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
include
script
src
.gitignore
LICENSE
Makefile
README.md
rebar.config

README.md

About

BESC is a StatsD client for Erlang.

Counter increments and timings are collected first and get dispatched every 2500 metrics or on timeout.

Installation

Add besc to your project of choice via rebar:

% rebar.config
{deps, [
    % Batched Erlang StatsD Client.
    {besc, "",
        {git, "git@github.com:wooga/besc.git",
        {branch, "stable"}}}
]}

The default configuration points to a StatsD server at 127.0.0.1 listening on port 3344, this can be changed however:

  • Override the configuration using application:set_env and friends:

    application:set_env(besc, host, "10.20.30.40"),
    application:set_env(besc, port, 1259),
    application:start(besc).
  • When building your own supervision tree:

    besc:start_link(Hostname, PortNum)
  • Or the custom start entirely: erlang besc:start(Hostname, PortNum).

Usage

Find an overview of the concept of timings and counters on the Flickr Blog.

  1. besc:inc(Key, By, Rate) increments a counter, where the fields are:

    • Key - A key describing what is being counted, interpreted as a string
    • By - The amount by which to increment the counter
    • Rate - The sampling rate
  2. besc:dec(Key, By, Rate) the opposite of inc, decrements a counter. Parameters are the same as with inc

  3. besc:time(Key, Value, Rate) measure how long a task took. Parameters are the same, except for By, which is labeled Value and reflects the task's duration in miliseconds

Examples

1> application:start(besc).
ok
2> {Duration, _} = timer:tc(timer, sleep, [random:uniform(100)]).
{46058,ok}
3> besc:time("sleep_duration", Duration, 0.75).
ok
4> besc:inc("noops", 1, 1.0).
ok

Received and subsequently interpreted on the server's side:

sleep_duration:46055|ms|@0.750000
noops:1|c|@1.000000

License

This project is licensed under the FreeBSD License. A copy of the license can be found in the repository.

Something went wrong with that request. Please try again.