readthedocs.org
c3b4bef6 - EmbedAPI: log success requests (#8689)

Commit
4 years ago
EmbedAPI: log success requests (#8689) * EmbedAPI: log success requests Log success requests using `django-structlog` and send them New Relic to know what projects are using EmbedAPI, if they are using sphinx-hoverxref and what version of it. This is the minimum configuration required to start using structlog + New Relic. If we are happy with the results we can migrate the other logs to structlog, which should be simple, but a little tedious to do search&replace. In the future, we can also set up django-structlog to log Celery tasks as well. * Minimal implementation of structlog for EmbedAPI Use structlog _only_ for EmbedAPI v2/v3 for now. We will do a test in production to this and decide the migration path for the whole codebase. * structlog: migrate application code to better logging Initial work to migrate our application to structlog for better logging, making them compatible with New Relic's integration. There are more work that can be done here to make it better. For example, more usage of `log.bind` to avoid repetition. Besides, rewriting some log message and reduce them to have more Canonical Log Lines (https://www.structlog.org/en/stable/logging-best-practices.html#canonical-log-lines) instead. * Make logs from `logging.getLogger` to look better Logs coming from `logging.getLogger` (from other applications) have the same structure that the ones logged by us via `structlog`. * Lint * Colored console locally and plain console in production * Use `SysLogProcessor` and `SysLogRenderer` to format the logs Use a custom renderer to match the structure we want: ``` %programname[%processid] [%level] %message [%logger:%linenumber] %structureddata ``` By default, rsyslog will prepend ``` %timestamp %hostname ``` and it will look exactly as we want. * Missing imports * Ignore `request_started` and `request_finished` events Co-authored-by: Eric Holscher <25510+ericholscher@users.noreply.github.com>
Author
Parents
Loading