Show More
@@ -34,6 +34,14 b' def get_user_agent(environ):' | |||||
34 | return environ.get('HTTP_USER_AGENT') |
|
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 | class RequestWrapperTween(object): |
|
45 | class RequestWrapperTween(object): | |
38 | def __init__(self, handler, registry): |
|
46 | def __init__(self, handler, registry): | |
39 | self.handler = handler |
|
47 | self.handler = handler | |
@@ -45,6 +53,11 b' class RequestWrapperTween(object):' | |||||
45 | start = time.time() |
|
53 | start = time.time() | |
46 | log.debug('Starting request time measurement') |
|
54 | log.debug('Starting request time measurement') | |
47 | response = None |
|
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 | try: |
|
61 | try: | |
49 | response = self.handler(request) |
|
62 | response = self.handler(request) | |
50 | finally: |
|
63 | finally: | |
@@ -56,12 +69,15 b' class RequestWrapperTween(object):' | |||||
56 | resp_code = getattr(response, 'status_code', 'UNDEFINED') |
|
69 | resp_code = getattr(response, 'status_code', 'UNDEFINED') | |
57 |
|
70 | |||
58 | total = time.time() - start |
|
71 | total = time.time() - start | |
|
72 | ||||
|
73 | _view_path = "{}/{}@{}".format(_path, vcs_method, repo_name) | |||
59 | log.info( |
|
74 | log.info( | |
60 | 'Req[%4s] IP: %s %s Request to %s time: %.4fs [%s], VCSServer %s', |
|
75 | 'Req[%4s] IP: %s %s Request to %s time: %.4fs [%s], VCSServer %s', | |
61 | count, ip, request.environ.get('REQUEST_METHOD'), |
|
76 | count, ip, request.environ.get('REQUEST_METHOD'), | |
62 |
_path, total, |
|
77 | _view_path, total, ua, _ver_, | |
63 | extra={"time": total, "ver": _ver_, "code": resp_code, |
|
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 | statsd = request.registry.statsd |
|
83 | statsd = request.registry.statsd | |
@@ -81,6 +97,7 b' class RequestWrapperTween(object):' | |||||
81 | "view_name:{}".format(match_route), |
|
97 | "view_name:{}".format(match_route), | |
82 | "code:{}".format(resp_code) |
|
98 | "code:{}".format(resp_code) | |
83 | ]) |
|
99 | ]) | |
|
100 | ||||
84 | return response |
|
101 | return response | |
85 |
|
102 | |||
86 |
|
103 |
General Comments 0
You need to be logged in to leave comments.
Login now