diff --git a/packages/service-library/src/servicelib/aiohttp/monitoring.py b/packages/service-library/src/servicelib/aiohttp/monitoring.py index 0ef4e3b0006..c3a90057584 100644 --- a/packages/service-library/src/servicelib/aiohttp/monitoring.py +++ b/packages/service-library/src/servicelib/aiohttp/monitoring.py @@ -21,7 +21,7 @@ from prometheus_client.registry import CollectorRegistry from servicelib.aiohttp.typing_extension import Handler -from ..logging_utils import catch_log_exceptions +from ..logging_utils import log_catch log = logging.getLogger(__name__) @@ -156,7 +156,7 @@ async def middleware_handler(request: web.Request, handler: Handler): try: log.debug("ENTERING monitoring middleware for %s", f"{request=}") if enter_middleware_cb: - with catch_log_exceptions(logger=log, reraise=False): + with log_catch(logger=log, reraise=False): await enter_middleware_cb(request) in_flight_gauge = request.app[kINFLIGHTREQUESTS] @@ -209,7 +209,7 @@ async def middleware_handler(request: web.Request, handler: Handler): ).inc() if exit_middleware_cb: - with catch_log_exceptions(logger=log, reraise=False): + with log_catch(logger=log, reraise=False): await exit_middleware_cb(request, resp) if log_exception: diff --git a/packages/service-library/src/servicelib/logging_utils.py b/packages/service-library/src/servicelib/logging_utils.py index 3620ae75d17..fb234653a37 100644 --- a/packages/service-library/src/servicelib/logging_utils.py +++ b/packages/service-library/src/servicelib/logging_utils.py @@ -176,7 +176,7 @@ def log_decorator_wrapper(*args, **kwargs): @contextmanager -def catch_log_exceptions(logger: logging.Logger, reraise: bool = True): +def log_catch(logger: logging.Logger, reraise: bool = True): try: yield except asyncio.CancelledError: