Skip to content
Snippets Groups Projects
Commit 9125f5f6 authored by Roman Shishkin's avatar Roman Shishkin
Browse files

Store http method in web app feature metrics

parent 42985b3f
No related branches found
Tags 0.5.1
No related merge requests found
Pipeline #2875 passed
......@@ -44,14 +44,18 @@ class WebAppFeature(AppFeature):
self.PROMETHEUS_ROUTE_METRIC = Counter(
'route',
documentation='Total route calls',
labelnames=('path', 'status'),
labelnames=('path', 'method', 'status'),
namespace=self.app.NAME,
)
@web.middleware
async def prometheus_route_call_count(request: web.Request, handler) -> web.Response:
resp = await handler(request)
self.PROMETHEUS_ROUTE_METRIC.labels(request.match_info.route.resource.canonical, resp.status).inc()
resp: web.Response = await handler(request)
self.PROMETHEUS_ROUTE_METRIC.labels(
request.match_info.route.resource.canonical,
request.method,
resp.status
).inc()
return resp
self.aiohttp_app = web.Application(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment