##// END OF EJS Templates
request-tracker: expose more info about repo-name/method in tracking calls
super-admin -
r1031:63ff36b5 default
parent child Browse files
Show More
@@ -34,6 +34,14 b' def get_user_agent(environ):'
34 34 return environ.get('HTTP_USER_AGENT')
35 35
36 36
37 def get_vcs_method(environ):
38 return environ.get('HTTP_X_RC_METHOD')
39
40
41 def get_vcs_repo(environ):
42 return environ.get('HTTP_X_RC_REPO_NAME')
43
44
37 45 class RequestWrapperTween(object):
38 46 def __init__(self, handler, registry):
39 47 self.handler = handler
@@ -45,6 +53,11 b' class RequestWrapperTween(object):'
45 53 start = time.time()
46 54 log.debug('Starting request time measurement')
47 55 response = None
56
57 ua = get_user_agent(request.environ)
58 vcs_method = get_vcs_method(request.environ)
59 repo_name = get_vcs_repo(request.environ)
60
48 61 try:
49 62 response = self.handler(request)
50 63 finally:
@@ -56,12 +69,15 b' class RequestWrapperTween(object):'
56 69 resp_code = getattr(response, 'status_code', 'UNDEFINED')
57 70
58 71 total = time.time() - start
72
73 _view_path = "{}/{}@{}".format(_path, vcs_method, repo_name)
59 74 log.info(
60 75 'Req[%4s] IP: %s %s Request to %s time: %.4fs [%s], VCSServer %s',
61 76 count, ip, request.environ.get('REQUEST_METHOD'),
62 _path, total, get_user_agent(request.environ), _ver_,
77 _view_path, total, ua, _ver_,
63 78 extra={"time": total, "ver": _ver_, "code": resp_code,
64 "path": _path, "view_name": match_route}
79 "path": _path, "view_name": match_route, "user_agent": ua,
80 "vcs_method": vcs_method, "repo_name": repo_name}
65 81 )
66 82
67 83 statsd = request.registry.statsd
@@ -81,6 +97,7 b' class RequestWrapperTween(object):'
81 97 "view_name:{}".format(match_route),
82 98 "code:{}".format(resp_code)
83 99 ])
100
84 101 return response
85 102
86 103
General Comments 0
You need to be logged in to leave comments. Login now