Optionally log remote ActivityPub objects to database
What does this MR do?
This PR implements "activity logging" to record inbound activities and fetched objects to the database. If enabled, inbox jobs are recorded with several metrics intended for debugging and research:
- Timestamp
- Processing duration
- Key ID
- User ID
- Verification status (did all auth checks pass?)
- Acceptance status (was the activity accepted?)
- Acceptance result (success code or error message)
- Activity JSON, excluding context
- Activity context (hash and JSON)
Fetched objects are recorded with these metrics:
- Timestamp
- Processing duration
- Remote hostname
- Requested URL
- Object URI / ID
- Acceptance status (was the activity accepted?)
- Acceptance result (success code or error message)
- Object JSON, excluding context
- Object context (hash and JSON)
As activity logging consumes a very large amount of database space, a daemon is provided to automatically purge old rows. The default setting is to prune rows only than 1 week, but this can be adjusted by the administrator. For especially tricky debugging, the preSave option will replace the final INSERT operation with an INSERT-UPDATE pair, which ensures that logs are captured even in the event of a hard-crash or OOM scenario. In exchange, the database load is further increased.
The table schema has been designed to respect GDPR and user consent. Validated activities are joined to the user who issued them, ensuring that account deletions will also purge all recorded logs. If necessary, further updates could join to the note table as well. Fetch logs are cleared upon receiving a Delete for the logged object's URI.
Contribution Guidelines
By submitting this merge request, you agree to follow our Contribution Guidelines
-
I agree to follow this project's Contribution Guidelines -
I have made sure to test this merge request