Skip to content

Commit 4a26ed2

Browse files
authored
Minghan/filter sentry wharton403 (#406)
* added patch * Better typechecking - Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
1 parent dca3135 commit 4a26ed2

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

backend/pennmobile/settings/production.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import sentry_sdk
44
from sentry_sdk.integrations.celery import CeleryIntegration
55
from sentry_sdk.integrations.django import DjangoIntegration
6+
from sentry_sdk.types import Event, Hint
67

78
from pennmobile.settings.base import * # noqa: F401, F403
89
from pennmobile.settings.base import DOMAINS, REDIS_URL
@@ -21,7 +22,22 @@
2122

2223
# Sentry settings
2324
SENTRY_URL = os.environ.get("SENTRY_URL", "")
24-
sentry_sdk.init(dsn=SENTRY_URL, integrations=[CeleryIntegration(), DjangoIntegration()])
25+
26+
27+
def before_send(event: Event, hint: Hint | None) -> Event | None:
28+
logentry = event.get("logentry")
29+
if isinstance(logentry, dict):
30+
message = logentry.get("message")
31+
if isinstance(message, str) and "Wharton: Error 403 when reserving data" in message:
32+
return None
33+
return event
34+
35+
36+
sentry_sdk.init(
37+
dsn=SENTRY_URL,
38+
integrations=[CeleryIntegration(), DjangoIntegration()],
39+
before_send=before_send,
40+
)
2541

2642
# DLA settings
2743
PLATFORM_ACCOUNTS = {"ADMIN_PERMISSION": "penn_mobile_admin"}

0 commit comments

Comments
 (0)