mozilla/openbadges — pull request #892 by thisandagain (2013-07-23 02:49:10+00:00)
Title: Statsd Implementation re: GH-793

I ported over some pieces of a statsd implementation that I've been using successfully on a few other projects. Essentially, this is just a thin wrapper on top of `node-statsd` to handle configuration and an express middleware addition. I have had problems with the alternative statsd client, `statsd-client` in production as it makes a few poor choices around wrapping async calls within synchronous interfaces.

For this implementation, I kept the application of the statsd middleware specific to the `POST /backpack/badge` and `POST /backpack/authenticate` routes as per the issue, but the middleware would probably be best applied globally unless the additional latency is prohibitive e.g.:
```javascript
app.use(middleware.statsdRequests());
```

Hope this is helpful!
http://www.youtube.com/watch?v=wusGIl3v044