From 9b04056a43253355661ca9e00406ecd6d82886bc Mon Sep 17 00:00:00 2001 From: Krzysztof Sulejczak Date: Mon, 4 Mar 2024 15:18:31 +0100 Subject: [PATCH 1/2] Use registry passed to `setup_prometheus_sensors` to generate metric view --- faust/sensors/prometheus.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/faust/sensors/prometheus.py b/faust/sensors/prometheus.py index 022dea146..747686d0d 100644 --- a/faust/sensors/prometheus.py +++ b/faust/sensors/prometheus.py @@ -73,7 +73,7 @@ async def metrics_handler(self: _web.View, request: _web.Request) -> _web.Respon return cast( _web.Response, - Response(body=generate_latest(REGISTRY), headers=headers, status=200), + Response(body=generate_latest(registry), headers=headers, status=200), ) From d03c50101f8aeb012ccfcc40ca40f0f9fb4a835f Mon Sep 17 00:00:00 2001 From: Krzysztof Sulejczak Date: Mon, 4 Mar 2024 15:37:13 +0100 Subject: [PATCH 2/2] refactor: import `web` once --- faust/sensors/prometheus.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/faust/sensors/prometheus.py b/faust/sensors/prometheus.py index 747686d0d..f3c497697 100644 --- a/faust/sensors/prometheus.py +++ b/faust/sensors/prometheus.py @@ -5,7 +5,7 @@ from aiohttp.web import Response -from faust import web, web as _web +from faust import web from faust.exceptions import ImproperlyConfigured from faust.types import ( TP, @@ -68,11 +68,11 @@ def setup_prometheus_sensors( app.monitor = PrometheusMonitor(metrics=faust_metrics) @app.page(pattern) - async def metrics_handler(self: _web.View, request: _web.Request) -> _web.Response: + async def metrics_handler(self: web.View, request: web.Request) -> web.Response: headers = {"Content-Type": CONTENT_TYPE_LATEST} return cast( - _web.Response, + web.Response, Response(body=generate_latest(registry), headers=headers, status=200), )