[trivial fix] Remove logging of health checks
Reduce the amount of repeated and otherwise not useful logging for health checks. Most of the time he book-ending request/response are useful for bounding other logs in the same requeest, the health check bounding logs provide little benefit. Change-Id: I486223bd92b3a6d5c7f6a11b3d9cc4153dd548a7
This commit is contained in:
parent
f8fb44b7a0
commit
89840303b1
@ -77,7 +77,8 @@ SECTIONS = [
|
||||
),
|
||||
cfg.DictOpt(
|
||||
'named_log_levels',
|
||||
default={"keystoneauth": logging.INFO},
|
||||
default={"keystoneauth": logging.INFO,
|
||||
"keystonemiddleware": logging.INFO},
|
||||
help=('The logging levels for named loggers. '
|
||||
'Use standard representations for logging levels: '
|
||||
'ERROR. WARN, INFO, DEBUG. Configuration file format: '
|
||||
|
@ -19,6 +19,7 @@ import re
|
||||
from shipyard_airflow.control import ucp_logging
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
HEALTH_URL = '/health'
|
||||
|
||||
|
||||
class LoggingMiddleware(object):
|
||||
@ -33,6 +34,8 @@ class LoggingMiddleware(object):
|
||||
ucp_logging.set_logvar('req_id', req.context.request_id)
|
||||
ucp_logging.set_logvar('external_ctx', req.context.external_marker)
|
||||
ucp_logging.set_logvar('user', req.context.user)
|
||||
if not req.url.endswith(HEALTH_URL):
|
||||
# Log requests other than the health check.
|
||||
LOG.info("Request %s %s", req.method, req.url)
|
||||
self._log_headers(req.headers)
|
||||
|
||||
@ -41,12 +44,21 @@ class LoggingMiddleware(object):
|
||||
"""
|
||||
ctx = req.context
|
||||
resp.append_header('X-Shipyard-Req', ctx.request_id)
|
||||
resp_code = self._get_resp_code(resp)
|
||||
|
||||
if req.url.endswith(HEALTH_URL):
|
||||
# Only log health checks upon failure. This prevents repeated
|
||||
# trivial logging due to constant health checks.
|
||||
if not resp_code == 204:
|
||||
LOG.error('Health check has failed with response status %s',
|
||||
resp.status)
|
||||
else:
|
||||
LOG.info('%s %s - %s', req.method, req.uri, resp.status)
|
||||
# TODO(bryan-strassner) since response bodies can contain sensitive
|
||||
# information, only logging error response bodies here. When we
|
||||
# have response scrubbing or way to categorize responses in the
|
||||
# future, this may be an appropriate place to utilize it.
|
||||
if self._get_resp_code(resp) >= 400:
|
||||
if resp_code >= 400:
|
||||
LOG.debug('Errored Response body: %s', resp.body)
|
||||
|
||||
def _log_headers(self, headers):
|
||||
|
Loading…
x
Reference in New Issue
Block a user