File tree Expand file tree Collapse file tree 5 files changed +277
-260
lines changed Expand file tree Collapse file tree 5 files changed +277
-260
lines changed Original file line number Diff line number Diff line change @@ -22,16 +22,14 @@ $ pip install blacksheep-prometheus
2222
2323## Usage
2424
25- A complete example that exposes prometheus metrics endpoint under ` /metrics/ ` path .
25+ A complete example that exposes prometheus metrics endpoint under default ` /metrics/ ` endpoint .
2626
2727``` python
2828from blacksheep.server import Application
29- from blacksheep_prometheus import PrometheusMiddleware, metrics
29+ from blacksheep_prometheus import use_prometheus_metrics
3030
3131app = Application()
32-
33- app.middlewares.append(PrometheusMiddleware())
34- app.router.add_get(' /metrics/' , metrics)
32+ use_prometheus_metrics(app)
3533```
3634
3735### Options
Original file line number Diff line number Diff line change 1+ from typing import Optional
2+
3+ from blacksheep .server import Application
4+
15from .middleware import PrometheusMiddleware
26from .view import metrics
37
8+
9+ def use_prometheus_metrics (
10+ app : Application ,
11+ * ,
12+ endpoint : str = "/metrics/" ,
13+ middleware : Optional [PrometheusMiddleware ] = None ,
14+ ) -> None :
15+ """
16+ Configures the given application to use Prometheus and provide services that can be
17+ injected in request handlers.
18+ """
19+ middleware = middleware or PrometheusMiddleware ()
20+ app .middlewares .append (middleware )
21+ app .router .add_get (endpoint , metrics )
22+
23+
424__all__ = [
5- 'metrics ' ,
25+ 'use_prometheus_metrics ' ,
626 'PrometheusMiddleware' ,
727]
You can’t perform that action at this time.
0 commit comments