Skip to content

wuub/prometheus_async

 
 

Repository files navigation

prometheus_async

image

image

prometheus_async adds support for asynchronous frameworks to the official Python client for the Prometheus metrics and monitoring system.

Currently asyncio (Python 3.4, 3.5) and Twisted (Python 2.6, 2.7, 3.4, 3.5, PyPy) are supported.

import asyncio

from aiohttp import web
from prometheus_client import Histogram
from prometheus_async.aio import time

REQ_TIME = Histogram("req_time_seconds", "time spent in requests")

@time(REQ_TIME)
async def req(request):
    await asyncio.sleep(1)
    return web.Response(body=b"hello")

Even for synchronous applications, the metrics exposure methods can be useful since they are more powerful than the one shipped with the official client. For that, helper functions have been added that run them in separate threads.

The source code is hosted on GitHub and the documentation on Read The Docs.

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%