feat: suppress uvicorn access logs for /health and /ready probes#5881
Open
jonpspri wants to merge 3 commits into
Open
feat: suppress uvicorn access logs for /health and /ready probes#5881jonpspri wants to merge 3 commits into
jonpspri wants to merge 3 commits into
Conversation
jonpspri
requested review from
Lang-Akshay,
brian-hussey,
crivetimihai,
ja8zyjits and
msureshkumar88
as code owners
July 25, 2026 12:24
jonpspri
force-pushed
the
feat/health-check-log-suppression
branch
from
July 25, 2026 12:29
6217957 to
773894f
Compare
Install a logging filter on the uvicorn.access logger from LoggingService.initialize() that drops access-log records for GET /health and GET /ready. Kubernetes and other orchestrators poll these endpoints on short intervals, generating high-volume, low-value log noise. All other endpoints and loggers are unaffected, and the filter never raises: any failure while formatting the message falls through to allow. Closes IBM#5880 Signed-off-by: Jonathan Springer <jps@s390x.com>
jonpspri
force-pushed
the
feat/health-check-log-suppression
branch
from
July 25, 2026 12:37
773894f to
d28d51d
Compare
Signed-off-by: Jonathan Springer <jps@s390x.com>
… compliance The diff-cover tool reported 88% coverage (below 93% threshold) on the health-check log suppression changes, specifically the except Exception block. This adds a test that patches getMessage() to raise an exception to ensure the filter handles it gracefully. Signed-off-by: Jonathan Springer <jps@s390x.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Install a
logging.Filteron theuvicorn.accesslogger fromLoggingService.initialize()that suppresses access-log records forGET /healthandGET /ready. Kubernetes and other orchestrators poll these endpoints on short intervals, generating high-volume, low-value log noise that drowns out useful request logs. All other endpoints (and non-uvicorn.accessloggers) are logged normally, and the filter never raises: any failure while formatting the message falls through to "allow".Matching the behavior on the contributing branch, the suppression is always-on (no config flag); happy to add an opt-out setting if maintainers prefer.
Closes #5880
Origin / framing
This change was discovered during the decomposition of PR #5417 into reviewable units. It was not part of the originally reviewed plan scope — it is offered here as a standalone, self-contained PR so that maintainers (or the original author) can decline it without any impact on the rest of the decomposition.
Overlap note
Sibling PR #5870 (log config file watcher) touches
mcpgateway/services/logging_service.pyin the sameLoggingService.initialize()region (log-level resolution) but not the same lines as this change. Whichever merges second should expect a trivial rebase; no semantic conflicts.Changes
mcpgateway/services/logging_service.py(+81):_UvicornHealthCheckFilter+LoggingService._install_uvicorn_health_check_filter(), installed duringinitialize()alongside the existing ClosedResourceError and httpx-sanitize filters.tests/unit/mcpgateway/services/test_logging_service.py(+98):TestUvicornHealthCheckFilter— suppresses/healthand/ready, passes/api/tools, ignores non-uvicorn.accessloggers, and survives malformed records and exceptions.docs/docs/manage/logging.md(+3): note documenting the suppression behavior.Test plan
pytest tests/unit/mcpgateway/services/test_logging_service.py— 36 passed (7 new)mainpytest --doctest-modules mcpgateway/services/logging_service.py)ruff check/ruff format/interrogate/ pre-commit hooks clean (2 pre-existing ruff findings in the test file onmainare untouched)