##// END OF EJS Templates
metrics: expose response code to logs
super-admin -
r1020:8172bf35 default
parent child Browse files
Show More
@@ -53,20 +53,20 b' class RequestWrapperTween(object):'
53 _path = safe_str(get_access_path(request.environ))
53 _path = safe_str(get_access_path(request.environ))
54 ip = '127.0.0.1'
54 ip = '127.0.0.1'
55 match_route = request.matched_route.name if request.matched_route else "NOT_FOUND"
55 match_route = request.matched_route.name if request.matched_route else "NOT_FOUND"
56 resp_code = getattr(response, 'status_code', 'UNDEFINED')
56
57
57 total = time.time() - start
58 total = time.time() - start
58 log.info(
59 log.info(
59 'Req[%4s] IP: %s %s Request to %s time: %.4fs [%s], VCSServer %s',
60 'Req[%4s] IP: %s %s Request to %s time: %.4fs [%s], VCSServer %s',
60 count, ip, request.environ.get('REQUEST_METHOD'),
61 count, ip, request.environ.get('REQUEST_METHOD'),
61 _path, total, get_user_agent(request.environ), _ver_,
62 _path, total, get_user_agent(request.environ), _ver_,
62 extra={"time": total, "ver": _ver_,
63 extra={"time": total, "ver": _ver_, "code": resp_code,
63 "path": _path, "view_name": match_route}
64 "path": _path, "view_name": match_route}
64 )
65 )
65
66
66 statsd = request.registry.statsd
67 statsd = request.registry.statsd
67 if statsd:
68 if statsd:
68 match_route = request.matched_route.name if request.matched_route else _path
69 match_route = request.matched_route.name if request.matched_route else _path
69 resp_code = getattr(response, 'status_code', 'UNDEFINED')
70 elapsed_time_ms = round(1000.0 * total) # use ms only
70 elapsed_time_ms = round(1000.0 * total) # use ms only
71 statsd.timing(
71 statsd.timing(
72 "vcsserver_req_timing.histogram", elapsed_time_ms,
72 "vcsserver_req_timing.histogram", elapsed_time_ms,
General Comments 0
You need to be logged in to leave comments. Login now