Skip to content

Instantly share code, notes, and snippets.

@jedi4ever
Last active December 20, 2015 04:09
Show Gist options
  • Save jedi4ever/6068660 to your computer and use it in GitHub Desktop.
Save jedi4ever/6068660 to your computer and use it in GitHub Desktop.
Comparing nodejs statsd clients (24/07/2013)

Node Clients:

  • reuse UDP connection: yes

  • prefix: yes

  • suffix: yes

  • dnscache: yes

  • mock: yes

  • samplerate: yes

  • errors: yes (eventemitter & bubbleup)

  • timing: yes

  • count: yes

  • increment: yes

  • decrement: yes

  • gauge: yes

  • set: yes

  • batch: yes

  • callback: yes

  • reuse UDP connection: yes (+ provide your own)

  • prefix: yes (called scope)

  • error: provide an error function

  • network : USE of ephemeral sockets!

  • samplerate: yes (use special random)

  • batching yes:

  • increment: yes

  • decrement: yes

  • timing: yes

  • gauge: yes

  • set: yes

special:

  • uses as stream in/out: yes (uses parser)
  • reuse UDP connections: yes (ephemeral socket)

  • prefix: yes

  • count: yes

  • gauges: yes

  • increment: yes

  • decrement: yes

  • sets: yes

  • timings: yes (delays)

special

  • socketTimeout: yes
  • children (multi prefix)
  • express helper: yes (or per URL)
  • reuse UDP: no

  • callback: yes (but default prints to console)

  • samplerate: yes

  • prefix: no

  • suffix: yes

  • batch: yes

  • count: yes

  • gauges: yes

  • increment: yes

  • decrement: yes

  • sets: yes (called modify)

  • timings: (delays)

(fork from node-statsd)

  • samplerate: yes

  • timing: yes

  • count: yes

  • increment: yes

  • decrement: yes

  • gauge: yes

  • set: ??

  • timingstart: yes

  • timignend: yes

special:

  • introduces: key aliases
  • transformKey function: YES

Note: you can safely ignore this lib

  • reuse UDP connection: no
  • timing: yes
  • count: yes
  • increment: yes
  • decrement: yes
  • gauge: yes
  • errors: total ignore
  • prefix: no
  • samplerate: no
  • callback: no

Note: use node-statsd instead unless cli is something special for you. The feature set is smaller than node-statsd and no special features, so we'll ignore this

  • udp connection reuse: no
  • timing: yes
  • counter: yes
  • increment: yes
  • decrement: yes
  • gauge: yes
  • rawSend: yes
  • samplerate: yes
  • batch: no

Mixing in express & connect:

Others:

Note: I've not included any specific backends here, we're focusing on generic statsd usage

What is a set in statsd?

Sets are acting like simple counters, with the additional specificity that it ignores duplicate values.

Technically, all values are stored in a set, and the number of elements in the set is sent to graphite during flushes. Sets are also emptied during flushes (in the same way that counters are reset to 0).

We have been using it in production for a while now, and it is working as expected. The use case that was used during the development of that feature was the following (it has been since extended to other cases as well):

We want to graph the number of active logged in users on the website.
Maintaining that state across application servers to manually update gauges is non-trivial.
We send a message to statsd containing the id of the user making a request.
statsd store all unique values between flushes, and sends the number of elements in the set to graphite.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment