INNER CODE UNIT · Python
PrometheusMiddleware
stephenhillier/starlette_exporter · starlette_exporter/middleware.py:123
class PrometheusMiddleware:
"""Middleware that collects Prometheus metrics for each request.
Use in conjuction with the Prometheus exporter endpoint handler.
"""
_metrics: ClassVar[Dict[str, MetricWrapperBase]] = {}
def __init__(
self,
app: ASGIApp,
group_paths: bool = True,
app_name: str = "starlette",
prefix: str = "starlette",
buckets: Optional[Sequence[Union[float, str]]] = None,
filter_unhandled_paths: bool = True,
skip_paths: Optional[List[str]] = None,
skip_methods: Optional[List[str]] = None,
optional_metrics: Optional[List[str]] = None,