Skip to content

Support Celery abstract tasks#1287

Merged
sl0thentr0py merged 3 commits intogetsentry:masterfrom
johnzeringue:celery-abstract-tasks
Jan 4, 2022
Merged

Support Celery abstract tasks#1287
sl0thentr0py merged 3 commits intogetsentry:masterfrom
johnzeringue:celery-abstract-tasks

Conversation

@johnzeringue
Copy link
Copy Markdown
Contributor

I have a use case for Celery abstract
tasks

to handle exceptions for an entire Celery app in a common way. Handled
exceptions should be swallowed in the abstract task and never make it to
Sentry.

Prior to this change, the Celery integration always instruments
task.run and incorrectly instruments task.__call__ (task(...) is
equivalent to type(task).__call__(...), not task.__call__(...)).
After this change, we'll use the same logic as Celery to decide whether
to instrument task.__call__ or task.run. That change allows abstract
tasks to catch/raise exceptions before the Sentry wrapper.

I have a use case for Celery [abstract
tasks](https://docs.celeryproject.org/en/latest/userguide/application.html#abstract-tasks)
to handle exceptions for an entire Celery app in a common way. Handled
exceptions should be swallowed in the abstract task and never make it to
Sentry.

Prior to this change, the Celery integration always instruments
`task.run` and incorrectly instruments `task.__call__` (`task(...)` is
equivalent to `type(task).__call__(...)`, not `task.__call__(...)`).
After this change, we'll use the same logic as Celery to decide whether
to instrument `task.__call__` or `task.run`. That change allows abstract
tasks to catch/raise exceptions before the Sentry wrapper.
@johnzeringue
Copy link
Copy Markdown
Contributor Author

Fixed the linting errors. Should be ready for another CI run

@sl0thentr0py
Copy link
Copy Markdown
Member

sl0thentr0py commented Jan 4, 2022

@johnzeringue thx for the contribution! Can you first rebase on master and push again?

@sl0thentr0py sl0thentr0py self-requested a review January 4, 2022 15:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants