CeleryIntegration wrongly reporting errors for tasks with custom __call__ method
See original GitHub issueEnvironment
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 here
Expected 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
CustomExceptionA
andCustomExceptionB
are shown by sentry as unhandled (although in fact they are as our other monitoring systems confirm)SpecialException
is 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.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Version 0.17.8 broke Celery tasks with custom Task class #844
I am using tenant-schemas-celery package, which generates it's own TenantTask (extends celery.app.task.Task) class in it's own CeleryApp ...
Read more >Celery - error handling and data storage - Stack Overflow
I see that results have statuses/states and stores results if requested -- when would I use this data? Should error handling and data...
Read more >Celery Documentation - Read the Docs
To call our task you can use the delay() method. ... Errors in this list will be reported as a failure to the...
Read more >Release Notes — ddtrace documentation
django: handle erroneous middleware gracefully. The tracer now captures the task ID from the cgroups file for Fargate >= 1.4.0 and reports it...
Read more >Custom Fields | sticky.io Help Center
A contact custom field will allow values to be stored in the field ... delete the incorrect custom field and restart the creation...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Quick update: I am looking into this
This issue has gone three weeks without activity. In another week, I will close it.
But! If you comment or otherwise update it, I will reset the clock, and if you label it
Status: Backlog
orStatus: In Progress
, I will leave it alone … forever!“A weed is but an unloved flower.” ― Ella Wheeler Wilcox 🥀