Page MenuHomeSoftware Heritage

gunicorn: disable sentry logging event reporting by default
ClosedPublic

Authored by olasd on Apr 13 2022, 3:10 PM.

Details

Summary

By default, sentry's logging integration will report any error or
exception-level logging as an event.

Now that we explicitly capture exceptions in the RPC server app, we can
disable this automatic event generation, and only use the logging
integration to generate breadcrumbs.

Test Plan

updated the gunicorn config tests to check that the logging integration is properly overridden

Diff Detail

Repository
rDCORE Foundations and core functionalities
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

Build is green

Patch application report for D7567 (id=27420)

Could not rebase; Attempt merge onto ab170ca98c...

Updating ab170ca..0b89e6b
Fast-forward
 swh/core/api/__init__.py                     | 19 +++++++
 swh/core/api/gunicorn_config.py              |  4 +-
 swh/core/api/tests/test_gunicorn.py          | 75 ++++++++++++++++++----------
 swh/core/api/tests/test_rpc_client_server.py | 34 ++++++++++++-
 swh/core/sentry.py                           | 23 ++++++++-
 5 files changed, 125 insertions(+), 30 deletions(-)
Changes applied before test
commit 0b89e6b1acba7d902914dc31d4f3da3eacd6d350
Author: Nicolas Dandrimont <nicolas@dandrimont.eu>
Date:   Wed Apr 13 15:05:19 2022 +0200

    gunicorn: disable sentry logging event reporting by default
    
    By default, sentry's logging integration will report any error or
    exception-level logging as an event.
    
    Now that we explicitly capture exceptions in the RPC server app, we can
    disable this automatic event generation, and only use the logging
    integration to generate breadcrumbs.

commit a310dd84f8c080019fd00bd4220c9c0c7ab7b532
Author: Nicolas Dandrimont <nicolas@dandrimont.eu>
Date:   Wed Apr 13 14:54:20 2022 +0200

    sentry: don't use mutable values as default arguments

commit b0fff3225d3078e3fcb81bef6bdbe5407b600d17
Author: Nicolas Dandrimont <nicolas@dandrimont.eu>
Date:   Wed Apr 13 14:16:45 2022 +0200

    RPC server: explicitly handle sentry exception capture
    
    The error handler for RPC server classes is used for both unexpected
    exceptions (using a 5xx status code), and exceptions used for the normal
    execution flow, which are encoded on the server side, and decoded to be
    raised again on the client side (and use a 4xx status code). We only
    record sentry errors for the 5xx class exceptions.

See https://jenkins.softwareheritage.org/job/DCORE/job/tests-on-diff/390/ for more details.

olasd requested review of this revision.Apr 13 2022, 3:12 PM
This revision is now accepted and ready to land.Apr 13 2022, 3:39 PM

Build is green

Patch application report for D7567 (id=27446)

Could not rebase; Attempt merge onto 5723f00a2a...

Updating 5723f00..8f2cfa8
Fast-forward
 swh/core/api/gunicorn_config.py     |  2 +
 swh/core/api/tests/test_gunicorn.py | 75 ++++++++++++++++++++++++-------------
 swh/core/sentry.py                  | 48 ++++++++++++++++++++++--
 swh/core/tests/test_sentry.py       | 68 +++++++++++++++++++++++++++++++++
 4 files changed, 162 insertions(+), 31 deletions(-)
 create mode 100644 swh/core/tests/test_sentry.py
Changes applied before test
commit 8f2cfa886c2f3473253adc9d93092f2c4d79bfd4
Author: Nicolas Dandrimont <nicolas@dandrimont.eu>
Date:   Wed Apr 13 15:05:19 2022 +0200

    gunicorn: disable sentry logging event reporting by default
    
    By default, sentry's logging integration will report any error or
    exception-level logging as an event.
    
    Now that we explicitly capture exceptions in the RPC server app, we can
    disable this automatic event generation, and only use the logging
    integration to generate breadcrumbs.

commit b9b898e3375374446838c8eda1fe33f64b3d232f
Author: Nicolas Dandrimont <nicolas@dandrimont.eu>
Date:   Thu Apr 14 11:24:26 2022 +0200

    Add support for disabling logging-based events in sentry
    
    add a configuration option to init_sentry to disable the error reporting
    from logging by sentry.
    
    This can be set via the SWH_SENTRY_DISABLE_LOGGING_EVENTS env var.
    Default behavior remains unchanged.
    
    Co-Authored-By: David Douard <david.douard@sdfa3.org>

See https://jenkins.softwareheritage.org/job/DCORE/job/tests-on-diff/397/ for more details.

This revision is now accepted and ready to land.Apr 14 2022, 1:48 PM