From a9566becfb97c65012b72bcc0adfb7ee84b0a4db Mon Sep 17 00:00:00 2001 From: Sidney Richards Date: Wed, 8 Jan 2025 11:50:53 +0100 Subject: [PATCH 1/3] Bump sentry sdk to 2.19.2 --- requirements/base.in | 2 +- requirements/base.txt | 3 ++- requirements/ci.txt | 4 +++- requirements/dev.txt | 4 +++- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/requirements/base.in b/requirements/base.in index f462f68815..442c4dc4f1 100644 --- a/requirements/base.in +++ b/requirements/base.in @@ -73,7 +73,7 @@ djangorestframework-camel-case # WSGI servers & monitoring - production oriented uwsgi -sentry-sdk # error monitoring +sentry-sdk[django] # error monitoring elastic-apm # Elastic APM integration beautifulsoup4 diff --git a/requirements/base.txt b/requirements/base.txt index 2363657554..dc86de12a1 100644 --- a/requirements/base.txt +++ b/requirements/base.txt @@ -146,6 +146,7 @@ django==4.2.16 # mozilla-django-oidc # mozilla-django-oidc-db # notifications-api-common + # sentry-sdk # zgw-consumers # zgw-consumers-oas django-admin-index==3.1.0 @@ -523,7 +524,7 @@ requests==2.31.0 # messagebird # mozilla-django-oidc # zgw-consumers -sentry-sdk==1.38.0 +sentry-sdk[django]==2.19.2 # via -r requirements/base.in simplejson==3.19.2 # via mail-parser diff --git a/requirements/ci.txt b/requirements/ci.txt index df56969440..c13b4092d2 100644 --- a/requirements/ci.txt +++ b/requirements/ci.txt @@ -238,6 +238,7 @@ django==4.2.16 # mozilla-django-oidc # mozilla-django-oidc-db # notifications-api-common + # sentry-sdk # zgw-consumers # zgw-consumers-oas django-admin-index==3.1.0 @@ -992,10 +993,11 @@ requests==2.31.0 # zgw-consumers requests-mock==1.12.1 # via -r requirements/test-tools.in -sentry-sdk==1.38.0 +sentry-sdk[django]==2.19.2 # via # -c requirements/base.txt # -r requirements/base.txt + # sentry-sdk simplejson==3.19.2 # via # -c requirements/base.txt diff --git a/requirements/dev.txt b/requirements/dev.txt index ad01732463..455e8a5be2 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -278,6 +278,7 @@ django==4.2.16 # mozilla-django-oidc # mozilla-django-oidc-db # notifications-api-common + # sentry-sdk # zgw-consumers # zgw-consumers-oas django-admin-index==3.1.0 @@ -1148,10 +1149,11 @@ requests-mock==1.12.1 # -r requirements/ci.txt roundrobin==0.0.4 # via locust -sentry-sdk==1.38.0 +sentry-sdk[django]==2.19.2 # via # -c requirements/ci.txt # -r requirements/ci.txt + # sentry-sdk simplejson==3.19.2 # via # -c requirements/ci.txt From 3cc0c0c049a964bd407b43f05a33c7171a49b7a0 Mon Sep 17 00:00:00 2001 From: Sidney Richards Date: Wed, 8 Jan 2025 15:47:50 +0100 Subject: [PATCH 2/3] Add an exception generating Celery task for debugging --- src/open_inwoner/celery.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/open_inwoner/celery.py b/src/open_inwoner/celery.py index 29620c429b..bc3ddd7614 100644 --- a/src/open_inwoner/celery.py +++ b/src/open_inwoner/celery.py @@ -70,3 +70,9 @@ def worker_shutdown(**_): app.steps["worker"].add(LivenessProbe) + + +@app.task +def trigger_exception(): + """Trigger an exception for debugging purposes.""" + return 1 / 0 From 31045d13fe1948d43be6790c632c1d1362860e83 Mon Sep 17 00:00:00 2001 From: Sidney Richards Date: Wed, 8 Jan 2025 15:49:29 +0100 Subject: [PATCH 3/3] Log a warning if Sentry cannot import Celery --- src/open_inwoner/conf/utils.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/open_inwoner/conf/utils.py b/src/open_inwoner/conf/utils.py index 2356a4ad8e..b14e08f037 100644 --- a/src/open_inwoner/conf/utils.py +++ b/src/open_inwoner/conf/utils.py @@ -46,7 +46,9 @@ def get_sentry_integrations() -> list: try: from sentry_sdk.integrations import celery except DidNotEnable: # happens if the celery import fails by the integration - pass + logger.warning( + "Unable to initialize Sentry with Celery integration due to failing import" + ) else: extra.append(celery.CeleryIntegration())