Skip to content

Instantly share code, notes, and snippets.

@ragnard
Created September 24, 2011 07:29
Show Gist options
  • Save ragnard/1239077 to your computer and use it in GitHub Desktop.
Save ragnard/1239077 to your computer and use it in GitHub Desktop.
StatsD Example
// Create a client for sending metrics to "localhost:8125", prefixing all keys with "foo.bar"
using(var client = new StatsClient("localhost", 8125, "foo.bar"))
{
// Increment a counter
client.Incremenet("counter1"); // sends 'foo.bar.counter1:1|c'
// Increment a counter by 42
client.Incremenet("counter2", 42); // sends 'foo.bar.counter2:1|c'
// Decrement a counter by 5, sampled every 1/10th time
client.Decrement("counter3", 5, 0.1); // sends 'foo.bar.counter3:-1|[email protected]
// Report that the blahonga operation took 42 ms
client.Timing("blahonga", 42); // sends 'foo.bar.blahonga:42|ms'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment