##// END OF EJS Templates
metrics: expose response code to logs
super-admin -
r4820:bfc036f6 default
parent child Browse files
Show More
@@ -56,6 +56,7 b' class RequestWrapperTween(object):'
56 _auth_user = self._get_user_info(request)
56 _auth_user = self._get_user_info(request)
57 ip = get_ip_addr(request.environ)
57 ip = get_ip_addr(request.environ)
58 match_route = request.matched_route.name if request.matched_route else "NOT_FOUND"
58 match_route = request.matched_route.name if request.matched_route else "NOT_FOUND"
59 resp_code = getattr(response, 'status_code', 'UNDEFINED')
59
60
60 total = time.time() - start
61 total = time.time() - start
61 log.info(
62 log.info(
@@ -63,12 +64,11 b' class RequestWrapperTween(object):'
63 count, _auth_user, request.environ.get('REQUEST_METHOD'),
64 count, _auth_user, request.environ.get('REQUEST_METHOD'),
64 _path, total, get_user_agent(request. environ), _ver_,
65 _path, total, get_user_agent(request. environ), _ver_,
65 extra={"time": total, "ver": _ver_, "ip": ip,
66 extra={"time": total, "ver": _ver_, "ip": ip,
66 "path": _path, "view_name": match_route}
67 "path": _path, "view_name": match_route, "code": resp_code}
67 )
68 )
68
69
69 statsd = request.registry.statsd
70 statsd = request.registry.statsd
70 if statsd:
71 if statsd:
71 resp_code = getattr(response, 'status_code', 'UNDEFINED')
72 elapsed_time_ms = round(1000.0 * total) # use ms only
72 elapsed_time_ms = round(1000.0 * total) # use ms only
73 statsd.timing(
73 statsd.timing(
74 "rhodecode_req_timing.histogram", elapsed_time_ms,
74 "rhodecode_req_timing.histogram", elapsed_time_ms,
General Comments 0
You need to be logged in to leave comments. Login now