feat: store warnings and request lines in log_events
The log now has a stored, queryable copy for the diagnostics console: every WARNING and above plus the request line of every request, kept for log_retention_days (default 7, no "forever") and pruned hourly by the new log_gc job. Rows are built on the logging thread from the same redacted fields as the stdout line, queued without blocking and written in batches by one background thread on its own connection. A full queue or a failed write drops and reports instead of retrying. Flood control keeps 30 of any one message per minute plus a count of the rest; anonymous request lines are capped at 60 a minute per client, and the client address is never stored. Deleting an account deletes its stored events. Measured on prod first: a YouTube RSS outage wrote 11k warnings in four hours, one per channel per poll. The poll now writes one warning with per-reason counts and a few examples, and a failure on our side gets one traceback per poll instead of one per channel.
This commit is contained in:
@@ -57,6 +57,10 @@ def _db_reachable() -> bool:
|
||||
|
||||
_DB_REACHABLE = _db_reachable()
|
||||
|
||||
# No background log writer in tests: every TestClient would otherwise start one on app startup and
|
||||
# write into tables the fixtures truncate between tests. The sink's own tests drive it explicitly.
|
||||
settings.log_db_sink = False
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
def _schema():
|
||||
|
||||
Reference in New Issue
Block a user