From e9cba7b7823ba846d9cca7e2477ddb9956c5cef4 Mon Sep 17 00:00:00 2001 From: RhodeCode Admin Date: Tue, 25 Oct 2022 13:59:47 +0200 Subject: [PATCH] metrics: fixed exc type metrics --- rhodecode/api/__init__.py | 2 +- rhodecode/config/middleware.py | 3 ++- rhodecode/lib/celerylib/loader.py | 2 +- rhodecode/lib/middleware/request_wrapper.py | 5 +++-- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/rhodecode/api/__init__.py b/rhodecode/api/__init__.py index aea2852e..4ae2ad6b 100644 --- a/rhodecode/api/__init__.py +++ b/rhodecode/api/__init__.py @@ -179,7 +179,7 @@ def exception_view(exc, request): statsd = request.registry.statsd if statsd: - statsd.incr('rhodecode_exception_total', tags=["exc_source:api"]) + statsd.incr('rhodecode_exception_total', tags=["exc_source:api", "type:{}".format(exc_info.type)]) return jsonrpc_error(request, fault_message, rpc_id) diff --git a/rhodecode/config/middleware.py b/rhodecode/config/middleware.py index a81c2f32..82369c2a 100644 --- a/rhodecode/config/middleware.py +++ b/rhodecode/config/middleware.py @@ -182,7 +182,8 @@ def error_handler(exception, request): statsd = request.registry.statsd if statsd and base_response.status_code > 499: - statsd.incr('rhodecode_exception_total', tags=["code:{}".format(base_response.status_code)]) + statsd.incr('rhodecode_exception_total', + tags=["exc_source:web", "type:{}".format(base_response.status_code)]) error_explanation = base_response.explanation or str(base_response) if base_response.status_code == 404: diff --git a/rhodecode/lib/celerylib/loader.py b/rhodecode/lib/celerylib/loader.py index feef20eb..75a5e71d 100644 --- a/rhodecode/lib/celerylib/loader.py +++ b/rhodecode/lib/celerylib/loader.py @@ -179,7 +179,7 @@ def task_failure_signal( store_exception(id(exc_info), exc_info, prefix='rhodecode-celery') statsd = StatsdClient.statsd if statsd: - statsd.incr('rhodecode_exception_total', tags=["exc_source:celery"]) + statsd.incr('rhodecode_exception_total', tags=["exc_source:celery", "type:{}".format(einfo.type)]) closer = celery_app.conf['PYRAMID_CLOSER'] if closer: diff --git a/rhodecode/lib/middleware/request_wrapper.py b/rhodecode/lib/middleware/request_wrapper.py index 9928c2c5..3da34a63 100644 --- a/rhodecode/lib/middleware/request_wrapper.py +++ b/rhodecode/lib/middleware/request_wrapper.py @@ -63,19 +63,20 @@ class RequestWrapperTween(object): statsd = request.registry.statsd if statsd: + match_route = request.matched_route.name if request.matched_route else _path resp_code = response.status_code elapsed_time_ms = 1000.0 * total statsd.timing( 'rhodecode_req_timing', elapsed_time_ms, tags=[ - "view_name:{}".format(request.matched_route.name), + "view_name:{}".format(match_route), #"user:{}".format(user_id), "code:{}".format(resp_code) ] ) statsd.incr( 'rhodecode_req_total', tags=[ - "view_name:{}".format(request.matched_route.name), + "view_name:{}".format(match_route), #"user:{}".format(user_id), "code:{}".format(resp_code) ])