Skip to content

[18.0][IMP] monitoring_log_requests: capture RPC params for audit replay#518

Open
dnplkndll wants to merge 5 commits into
camptocamp:18.0from
ledoent:18.0-imp-monitoring_log_requests-params
Open

[18.0][IMP] monitoring_log_requests: capture RPC params for audit replay#518
dnplkndll wants to merge 5 commits into
camptocamp:18.0from
ledoent:18.0-imp-monitoring_log_requests-params

Conversation

@dnplkndll
Copy link
Copy Markdown
Contributor

Summary

Add optional RPC parameter capture to request logs, enabling operation replay from logs on a backup database.

Changes

  • Add _sanitize_params() helper that strips binary data, truncates large strings, and caps total size
  • Log args and kwargs from RPC calls alongside model/method
  • Controlled by MONITORING_LOG_PARAMS_MAX_SIZE env var (default 4096, set 0 to disable)

Use case

When investigating production issues, the captured params allow replaying the exact operations on a database backup to understand what happened and when.

Depends on: #FIX PR above

dnplkndll and others added 5 commits March 26, 2026 18:16
- Add /websocket to blacklist (Odoo 18 uses websockets for bus)
- Fix response_status_code: hasattr checked request instead of response,
  and wrote to wrong key (status_code vs response_status_code)
- Add default "" for PATH_INFO to avoid NoneType.startswith error
Add optional parameter capture to request logs for audit trail and
replay capability. Controlled by MONITORING_LOG_PARAMS_MAX_SIZE env
var (default 4096 bytes, set to 0 to disable).

Parameters are sanitized before logging:
- Binary data (bytes) is excluded
- Large strings (>1000 chars) are replaced with length summary
- Nested structures limited to 3 levels depth
- Lists truncated to 20 items, dicts to 30 keys
- Total serialized size capped at max_size
Wrap super()._dispatch in try/except/finally so that requests which raise
also produce a monitoring.http.requests log entry. Adds exception_type
and exception_message fields, and logs at ERROR with exc_info when an
exception occurred. Successful requests continue to log at INFO.

Closes the observability gap where failed XMLRPC/JSONRPC calls were
captured by Sentry but absent from the request log stream (odoo_rpc).
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