Andy McKay

Oct 08, 2012

django-statsd 0.3.8 - nose plugin


We use Statsd in combination with Django through django-statsd. The timing and profiling information it provides is really useful on a live site. The information can also be useful for debugging and developing locally, for example by exposing in django-debug-toolbar.

How about unit tests? Well here's a nose plugin to expose that information. Combined with the patches inside django-statsd you can quickly get some useful information. Run your tests with the following plugin:

--with-statsd

You should (hopefully) get some nice information. This is the output when running with all the patches in solitude.

======================================================================
Statsd Keys                       | Number | Avg (ms) | Total (ms)
----------------------------------------------------------------------
cache.memcached.clear             |    222 | 0.202703 | 45.000
cache.memcached.delete            |      1 | 1.000000 | 1.000
cache.memcached.get               |      7 | 0.428571 | 3.000
cache.memcached.set               |      7 | 0.000000 | 0.000
db.mysql.default.execute          |    572 | 0.575175 | 329.000
solitude.paypal.check-purchase    |      3 | 0.666667 | 2.000
solitude.paypal.get-pay-key       |      9 | 0.444444 | 4.000
solitude.paypal.get-refund        |      5 | 0.000000 | 0.000
solitude.paypal.get-verified      |      3 | 0.666667 | 2.000
solitude.paypal.ipn.validate      |     11 | 0.000000 | 0.000
solitude.proxy.paypal.get-pay-key |      6 | 0.333333 | 2.000
======================================================================
Statsd Counts                     | Number | Total
----------------------------------------------------------------------
solitude.paypal.post              |     23 | 23
----------------------------------------------------------------------
Ran 228 tests in 2.635s