[Twisted-Python] [ANN] prometheus_async: asyncio/Twisted-aware Python Prometheus instrumentation

Hynek Schlawack hs at ox.cx
Fri May 20 01:53:13 MDT 2016


Dear fellow friends of asynchronous software,

maybe some of you have already bumped into the Prometheus monitoring system <https://prometheus.io> and liked it like I do (in any case, I’d like to invite you to my PyCon US talk on that topic: <https://us.pycon.org/2016/schedule/presentation/1601/>!)

And while it’s great that Python is a first class citizen due to the official Python client library <https://github.com/prometheus/client_python>, asyncio and Twisted sadly aren’t!

That’s why I’ve just released prometheus_async: https://prometheus-async.readthedocs.io/

First and foremost it wraps the metrics from the official client (you don’t want *me* to do math!) and makes them work properly on coroutines and Deferreds (and makes them well-behaved decorators too but that’s a topic for another day…).

Additionally, it adds a few goodies:

- Metric-exposure via aiohttp that ist much more flexible than what comes with the stdlib-based official solution.
- …that can also be started in a separate thread.  That means you can use them in regular, *synchronous* Python 3 applications as well (I instrument all my Pyramid apps like that).
- Integration with service discovery.  Listen on port 0 and leave registration to Consul Agent (integration is pluggable, just implement two methods)!

Sadly the goodies are asyncio-only so far.  Partly because the official client has some Twisted Web support merged but not released yet.  Contributions are very welcome!

Cheers,
Hynek


More information about the Twisted-Python mailing list