feat(logging): add request payload retention - #164
Conversation
|
please fix the conflicts |
astaxie
left a comment
There was a problem hiding this comment.
Maintainer summary for current head 970ae452: the implementation remains blocked by merge conflicts with current main, even though the focused cleanup tests, go vet, repository gates, and all three Compose renders passed in the prior isolated review of this unchanged head.
A fresh git merge-tree against current main reproduces content conflicts in deploy/.env.example, deploy/docker-compose.yml, deploy/docker-compose.postgres.yml, and deploy/docker-compose.remote-postgres.yml. Please rebase or merge current main, reconcile the environment contract consistently across all Compose variants, then rerun the full deployment/environment checks and CI. No PR branch changes or workflow runs were triggered.
Summary
Add an opt-in retention policy for request and response payload logs so operators can bound sensitive payload storage and prevent unbounded SQLite growth without removing request metadata, usage, routing, or billing records.
The new
TOKENHUB_REQUEST_PAYLOAD_RETENTION_DAYSsetting defaults to0, preserving the existing no-cleanup behavior. A positive value retains that many days of payload logs.Related Issue
N/A.
Changes
TOKENHUB_REQUEST_PAYLOAD_RETENTION_DAYS; reject negative and non-numeric values at startup.request_payload_logsolder than the cutoff in independently committed batches of 500 rows.request_payload_logs.created_at, using concurrent creation on PostgreSQL.VACUUMas an explicit operator action so deleted SQLite pages remain available for reuse.start.sh, and English, Simplified Chinese, and Japanese deployment docs.Type of Change
Verification
go test ./...go vet ./...node --test tools/*.test.mjs(103/103 passed)node tools/check-doc-translations.mjs --base upstream/main --head HEADnode tools/check-ui-translations.mjsnode tools/check-env-contract.mjsnode tools/check-source-lines.mjsgit diff --checkCompatibility, Security, and Operations
The default value is
0, so upgrades retain all payload logs unless an operator opts in. The cleanup changes no API and does not modify the existing 64 KiB payload capture limits. It deletes onlyrequest_payload_logs; request metadata, usage, route attempts, and billing data are unaffected.A positive retention value permanently deletes expired payload bodies. Rollback is immediate by setting the value back to
0, but already deleted payloads require a database backup to recover. SQLite reuses freed pages but does not return space to the operating system until an operator performsVACUUM. Initial index creation and historical cleanup may take time on a large database and should be deployed during a low-traffic period.Checklist
.envfiles, databases, backups, or runtime logs are included.start.sh, and deployment documentation where applicable.data/model-catalog.yamlremains tracked and catalog changes were reviewed where applicable.git diff --checkpasses.