Skip to main content

Prometheus exporter for aiohttp server and client.

Project description

https://img.shields.io/pypi/v/aiohttp_prometheus_exporter.svg https://img.shields.io/travis/adriankrupa/aiohttp_prometheus_exporter.svg https://img.shields.io/pypi/pyversions/aiohttp_prometheus_exporter.svg https://img.shields.io/pypi/dm/aiohttp_prometheus_exporter.svg https://codecov.io/gh/adriankrupa/aiohttp_prometheus_exporter/branch/master/graph/badge.svg Black Documentation Status Updates

Export aiohttp metrics for Prometheus.io

Usage

Requirements

  • aiohttp >= 3

Installation

Install with:

pip install aiohttp-prometheus-exporter

Server quickstart

from aiohttp import web
from aiohttp_prometheus_exporter.handler import metrics
from aiohttp_prometheus_exporter.middleware import prometheus_middleware_factory

async def hello(request):
    return web.Response(text="Hello, world")

app = web.Application()
app.add_routes([web.get('/', hello)])

app.middlewares.append(prometheus_middleware_factory())
app.router.add_get("/metrics", metrics())

web.run_app(app)

Client quickstart

import aiohttp
from aiohttp_prometheus_exporter.trace import PrometheusTraceConfig

async with aiohttp.ClientSession(trace_configs=[PrometheusTraceConfig()) as session:
    async with session.get('http://httpbin.org/get') as resp:
        print(resp.status)
        print(await resp.text())

Now, client metrics are attached to metrics exposed by your web server.

Credits

This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.

History

0.2.4 (2020-04-07)

  • Fixed building problems

  • Configured black linter

0.1.0 (2020-04-07)

  • First release on PyPI.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aiohttp_prometheus_exporter-0.2.4.tar.gz (15.9 kB view hashes)

Uploaded Source

Built Distribution

aiohttp_prometheus_exporter-0.2.4-py2.py3-none-any.whl (7.5 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page