Fix TaskErrors being reported to Sentry

This commit is contained in:
rubenwardy 2024-05-01 21:29:36 +01:00
parent 662c632f5d
commit faddf11f77

@ -35,6 +35,14 @@ from sentry_sdk.integrations.flask import FlaskIntegration
if os.getenv("SENTRY_DSN"): if os.getenv("SENTRY_DSN"):
def before_send(event, hint):
from app.tasks import TaskError
if "exc_info" in hint:
exc_type, exc_value, tb = hint["exc_info"]
if isinstance(exc_value, TaskError):
return None
return event
environment = os.getenv("SENTRY_ENVIRONMENT") environment = os.getenv("SENTRY_ENVIRONMENT")
assert environment is not None assert environment is not None
sentry_sdk.init( sentry_sdk.init(
@ -49,6 +57,8 @@ if os.getenv("SENTRY_DSN"):
# of sampled transactions. # of sampled transactions.
# We recommend adjusting this value in production. # We recommend adjusting this value in production.
profiles_sample_rate=1.0, profiles_sample_rate=1.0,
before_send=before_send,
) )