scivey / aiostatsd

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

aiostatsd

An asyncio statsd client for Python >= 3.4. The underlying protocol is written in cython, which we can all admit is pretty cool.

It automatically batches multiple metrics in single UDP packets, with a configurable target packet size of 512 bytes. The flush interval defaults to 0.5 seconds, but can also be configured.

Install

pip install aiostatsd

Example

import asyncio
from aiostatsd.client import StatsdClient

async def go():
    client = StatsdClient("127.0.0.1", 8015)
    asyncio.ensure_future(client.run())
    with client.timer("something", rate=0.1):
        await asyncio.sleep(0.5)
    client.incr("x")
    client.decr("y", 5)
    client.send_gauge("queue_depth", 50)
    await client.stop()

if __name__ == '__main__':
    asyncio.get_event_loop().run_until_complete(go())

License

MIT

About


Languages

Language:Python 100.0%