Add health check endpoint (#8048)

This commit is contained in:
Erik Johnston 2020-08-07 14:21:24 +01:00 committed by GitHub
parent 4dd27e6d11
commit 7620912d84
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 90 additions and 3 deletions

View file

@ -286,7 +286,9 @@ class SynapseRequest(Request):
# the connection dropped)
code += "!"
self.site.access_logger.info(
log_level = logging.INFO if self._should_log_request() else logging.DEBUG
self.site.access_logger.log(
log_level,
"%s - %s - {%s}"
" Processed request: %.3fsec/%.3fsec (%.3fsec, %.3fsec) (%.3fsec/%.3fsec/%d)"
' %sB %s "%s %s %s" "%s" [%d dbevts]',
@ -314,6 +316,11 @@ class SynapseRequest(Request):
except Exception as e:
logger.warning("Failed to stop metrics: %r", e)
def _should_log_request(self) -> bool:
"""Whether we should log at INFO that we processed the request.
"""
return self.path != b"/health"
class XForwardedForRequest(SynapseRequest):
def __init__(self, *args, **kw):