# HG changeset patch # User RhodeCode Admin # Date 2022-10-14 11:52:39 # Node ID f0b7e732f18cbd754915363114c2fe969f0a813a # Parent a753a912439b3a5087784f9c54b9a9e616acd6d3 metrics: add response code, and fix user problem on metrics diff --git a/rhodecode/lib/middleware/request_wrapper.py b/rhodecode/lib/middleware/request_wrapper.py --- a/rhodecode/lib/middleware/request_wrapper.py +++ b/rhodecode/lib/middleware/request_wrapper.py @@ -63,18 +63,22 @@ class RequestWrapperTween(object): statsd = request.registry.statsd if statsd: + resp_code = response.status_code + user_id = getattr(_auth_user, 'user_id', _auth_user) elapsed_time_ms = 1000.0 * total statsd.timing( 'rhodecode_req_timing', elapsed_time_ms, tags=[ "path:{}".format(_path), - "user:{}".format(_auth_user.user_id) + "user:{}".format(user_id), + "code:{}".format(resp_code) ] ) statsd.incr( 'rhodecode_req_count', tags=[ "path:{}".format(_path), - "user:{}".format(_auth_user.user_id) + "user:{}".format(user_id), + "code:{}".format(resp_code) ]) return response