Module

_metrics_handler

Built-in /metrics endpoint for Prometheus scraping.

Provides a lightweight ASGI app that serves metrics from a PrometheusCollector at a configurable path (default: /metrics).

Functions

create_metrics_app 2 Callable
Create an ASGI app that serves Prometheus metrics. This wraps the user's ASGI …
def create_metrics_app(collector: PrometheusCollector, metrics_path: str = '/metrics') -> Callable

Create an ASGI app that serves Prometheus metrics.

This wraps the user's ASGI app and intercepts requests to the metrics path, serving Prometheus text format metrics from the collector.

Parameters
Name Type Description
collector PrometheusCollector

PrometheusCollector instance with metrics

metrics_path str

Path to serve metrics at (default: "/metrics")

Default:'/metrics'
Returns
Callable
wrap_app_with_metrics 3 Callable
Wrap an ASGI app to intercept metrics requests. Requests to `metrics_path` are…
def wrap_app_with_metrics(app: Callable, collector: PrometheusCollector, metrics_path: str = '/metrics') -> Callable

Wrap an ASGI app to intercept metrics requests.

Requests tometrics_pathare handled by the metrics handler. All other requests are passed to the original app.

Parameters
Name Type Description
app Callable

Original ASGI app

collector PrometheusCollector

PrometheusCollector instance

metrics_path str

Path to serve metrics at

Default:'/metrics'
Returns
Callable