-
Notifications
You must be signed in to change notification settings - Fork 603
CeleryIntegration wrongly reporting errors for tasks with custom __call__ method #1137
Copy link
Copy link
Closed
Closed
Copy link
Labels
Description
Environment
How do you use Sentry?
Sentry SaaS (sentry.io)
Which SDK and version?
Python 1.1.0
Steps to Reproduce
- Create a custom celery base task class
- Implement a custom
__call__method on that base task class - Catch and handle certain exceptions in that
__call__method - Raise a different exception from the custom
__call__method
Example code:
from celery import Task
class CustomBaseTask(Task):
def __call__(self, *args, **kwargs):
try:
super().__call__(*args, **kwargs)
except CustomExceptionA:
# do sth
raise SpecialException()
except CustomExceptionB:
pass
@shared_task(base=CustomBaseTask, bind=True)
def some_actual_task(self, ...):
... # do sth hereExpected Result
- Errors caught in the custom
__call__method should not be sent to sentry (i.e.,CustomExceptionA,CustomExceptionB) - Errors raised in the custom
__call__method should be sent to sentry (i.e.,SpecialException)
Actual Result
CustomExceptionAandCustomExceptionBare shown by sentry as unhandled (although in fact they are as our other monitoring systems confirm)SpecialExceptionis never shown in sentry, although it is being raised (confirmed by our other monitoring systems)
From debugging it seems that sentry wraps the task's run method, which is called by the celery.Task.__call__ method and thus at a lower level than the custom call method.
Also it seems that sentry's attempted wrap of the task's __call__ method is not working, since SpecialException is never sent to sentry.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Fields
Give feedbackNo fields configured for issues without a type.