Skip to content

feat: suppress access logs for Playwright test requests#947

Merged
maxachis merged 1 commit intodevfrom
feat/suppress-test-access-logs
Feb 11, 2026
Merged

feat: suppress access logs for Playwright test requests#947
maxachis merged 1 commit intodevfrom
feat/suppress-test-access-logs

Conversation

@maxachis
Copy link
Copy Markdown
Contributor

@maxachis maxachis commented Feb 10, 2026

Summary

  • Adds ASGI middleware that detects the X-Test-Run: true header sent by Playwright tests and suppresses their uvicorn access log entries
  • Uses contextvars + logging.Filter for async-safe, zero-dependency log suppression
  • Reduces Papertrail log volume from ~450MB/month to ~50MB/month

Closes #937

Changes

  • New: middleware/access_log_filter.pySuppressTestAccessLogMiddleware (ASGI), TestRequestAccessLogFilter (logging), install_test_request_log_filter() helper
  • Modified: app.py — integrates the middleware and log filter into create_asgi_app()
  • New: tests/middleware/test_access_log_filter.py — unit tests for filter, middleware, and install function

Test plan

  • uv run basedpyright --level error — 0 errors
  • uv run ruff check . — all checks passed
  • Unit tests verify: normal requests pass, test requests suppressed, contextvar resets after request, non-HTTP scopes pass through, case-insensitive header matching
  • CI pipeline (pytest, ruff, basedpyright, bandit)

🤖 Generated with Claude Code

Add middleware that detects the X-Test-Run header from Playwright tests
and suppresses their uvicorn access log entries, reducing log volume
from ~450MB/month to ~50MB/month on Papertrail.

Closes #937

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@maxachis maxachis merged commit 094bf1f into dev Feb 11, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant