kruxstatsd

Wrapper around pystatsd with automatic namespacing


License
MIT
Install
pip install kruxstatsd==0.2.2

Documentation

kruxstatsd

kruxstatsd is a wrapper library around pystatsd. It will format stats based on a provided prefix (just like pystatsd), environment, and the host the client is running on. For example, incrementing the following stat on a host called ops-dev004.krxd.net:

import kruxstatsd

k = kruxstatsd.StatsClient('js', env='stage')
k.incr('foo')

will create a counter stat named 'stage.js.foo.ops-dev004'.

Similarly, the following:

k.timing('foo', 'TIME')

will create a timer stat named 'stage.js.foo.ops-dev004'.

Usage

To use kruxstatsd, simply import it instead of pystatsd. The interface is exactly the same. Context managers will also continue to work:

with k.timer('expensive_op'):
    func()