mirror of
https://github.com/outbackdingo/patroni.git
synced 2026-08-25 14:53:37 +00:00
Enable debug logging for GET/OPTIONS API calls together with latency
This commit is contained in:
committed by
Alexander Kukushkin
parent
47c3dc2352
commit
1d3fd3ac0b
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user