diff --git a/pyms/flask/services/metrics.py b/pyms/flask/services/metrics.py index 1525843..fd00856 100644 --- a/pyms/flask/services/metrics.py +++ b/pyms/flask/services/metrics.py @@ -30,9 +30,13 @@ def before_request(self): # pylint: disable=R0201 request.start_time = time.time() def after_request(self, response): + if hasattr(request.url_rule, "rule"): + path = request.url_rule.rule + else: + path = request.path request_latency = time.time() - request.start_time - FLASK_REQUEST_LATENCY.labels(self.app_name, request.method, request.path, response.status_code).observe(request_latency) - FLASK_REQUEST_COUNT.labels(self.app_name, request.method, request.path, response.status_code).inc() + FLASK_REQUEST_LATENCY.labels(self.app_name, request.method, path, response.status_code).observe(request_latency) + FLASK_REQUEST_COUNT.labels(self.app_name, request.method, path, response.status_code).inc() return response