##// END OF EJS Templates
logging: update request wrapper to expose additional data points
super-admin -
r1017:a6b2d02d default
parent child Browse files
Show More
@@ -44,24 +44,29 b' class RequestWrapperTween(object):'
44 44 def __call__(self, request):
45 45 start = time.time()
46 46 log.debug('Starting request time measurement')
47 response = None
47 48 try:
48 49 response = self.handler(request)
49 50 finally:
50 51 count = request.request_count()
51 52 _ver_ = vcsserver.__version__
52 53 _path = safe_str(get_access_path(request.environ))
54 ip = '127.0.0.1'
55 match_route = request.matched_route.name if request.matched_route else "NOT_FOUND"
53 56
54 57 total = time.time() - start
55 58 log.info(
56 59 'Req[%4s] IP: %s %s Request to %s time: %.4fs [%s], VCSServer %s',
57 count, '127.0.0.1', request.environ.get('REQUEST_METHOD'),
58 _path, total, get_user_agent(request.environ), _ver_
60 count, ip, request.environ.get('REQUEST_METHOD'),
61 _path, total, get_user_agent(request.environ), _ver_,
62 extra={"time": total, "ver": _ver_,
63 "path": _path, "view_name": match_route}
59 64 )
60 65
61 66 statsd = request.registry.statsd
62 67 if statsd:
63 68 match_route = request.matched_route.name if request.matched_route else _path
64 resp_code = response.status_code
69 resp_code = getattr(response, 'status_code', 'UNDEFINED')
65 70 elapsed_time_ms = round(1000.0 * total) # use ms only
66 71 statsd.timing(
67 72 "vcsserver_req_timing.histogram", elapsed_time_ms,
General Comments 0
You need to be logged in to leave comments. Login now