# _metrics_handler

URL: /pounce/api/_metrics_handler/
Section: api
Description: Built-in /metrics endpoint for Prometheus scraping.

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

---

> For a complete page index, fetch /pounce/llms.txt.

Open LLM text
(/pounce/api/_metrics_handler/index.txt)

Share with AI

Ask Claude
(https://claude.ai/new?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fpounce%2Fapi%2F_metrics_handler%2Findex.txt)

Ask ChatGPT
(https://chatgpt.com/?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fpounce%2Fapi%2F_metrics_handler%2Findex.txt)

Ask Gemini
(https://gemini.google.com/app?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fpounce%2Fapi%2F_metrics_handler%2Findex.txt)

Ask Copilot
(https://copilot.microsoft.com/?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fpounce%2Fapi%2F_metrics_handler%2Findex.txt)

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).

2Functions

## 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 (/pounce/api/metrics/#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 to`metrics_path`are 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 (/pounce/api/metrics/#PrometheusCollector)`

PrometheusCollector instance

`metrics_path`
`str`

Path to serve metrics at

Default:`'/metrics'`

##### Returns

`Callable`
