Enable debug logging for GET/OPTIONS API calls together with latency

This commit is contained in:
Jan Tomsa
2019-07-01 10:50:39 +02:00
committed by Alexander Kukushkin
parent 47c3dc2352
commit 1d3fd3ac0b
+7
View File
@@ -86,6 +86,9 @@ class RestApiHandler(BaseHTTPRequestHandler):
def do_GET(self, write_status_code_only=False):
"""Default method for processing all GET requests which can not be routed to other methods"""
time_start = time.time()
request_type = 'OPTIONS' if write_status_code_only else 'GET'
path = '/master' if self.path == '/' else self.path
response = self.get_postgresql_status()
@@ -124,6 +127,10 @@ class RestApiHandler(BaseHTTPRequestHandler):
else:
self._write_status_response(status_code, response)
time_end = time.time()
self.log_message('%s %s %s latency: %s ms', request_type, path,
status_code, (time_end - time_start) * 1000)
def do_OPTIONS(self):
self.do_GET(write_status_code_only=True)