diff --git a/sentry_sdk/integrations/celery.py b/sentry_sdk/integrations/celery.py index 5b7646d429..5a616d47a7 100644 --- a/sentry_sdk/integrations/celery.py +++ b/sentry_sdk/integrations/celery.py @@ -2,7 +2,12 @@ import sys -from celery.exceptions import SoftTimeLimitExceeded, Retry # type: ignore +from celery.exceptions import ( # type: ignore + SoftTimeLimitExceeded, + Retry, + Ignore, + Reject, +) from sentry_sdk.hub import Hub from sentry_sdk.utils import capture_internal_exceptions, event_from_exception @@ -11,6 +16,9 @@ from sentry_sdk.integrations.logging import ignore_logger +CELERY_CONTROL_FLOW_EXCEPTIONS = (Retry, Ignore, Reject) + + class CeleryIntegration(Integration): identifier = "celery" @@ -106,7 +114,7 @@ def _capture_exception(task, exc_info): if hub.get_integration(CeleryIntegration) is None: return - if isinstance(exc_info[1], Retry): + if isinstance(exc_info[1], CELERY_CONTROL_FLOW_EXCEPTIONS): return if hasattr(task, "throws") and isinstance(exc_info[1], task.throws): return