[celery integration] before_send function executed twice
See original GitHub issueDoing a simple test with sentry and celery integration I see the function before_send
gets executed twice when an exception is raised while the on_failure
celery task mechanism gets executed correctly once.
Setup:
# within my make_celery() function to create the celery app
def before_send(event, hint):
print('before_send celery integration')
return event
sentry_sdk.init(dsn=url, integrations=[CeleryIntegration(), SqlalchemyIntegration()], before_send=before_send)
on_failure
celery callback handler
def on_failure(task, exc, task_id, args, _, exception_info, **__):
logger.error("on_failure error print")
celery task:
@celery.task(bind=True, name="test_sentry_integration", on_failure=on_failure, ignore_result=True)
def test_sentry_integration(_, message):
raise Exception(message)
output:
[2019-11-15 11:02:13,148: WARNING/ForkPoolWorker-1] test the sdk
[2019-11-15 11:02:13,152: WARNING/ForkPoolWorker-1] before_send celery integration
2019-11-15 11:02:13,159::comfortmanager.common.tasks::ERROR::on_failure error print
[2019-11-15 11:02:13,161: WARNING/ForkPoolWorker-1] before_send celery integration
[2019-11-15 11:02:13,161: ERROR/ForkPoolWorker-1] Task test_sentry_integration[2f5848b3-1e12-4a0d-92e2-0b4dec63e7c8] raised unexpected: Exception('test the sdk',)
Versions:
celery 4.3.0
sentry-sdk 0.13.2
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Task is executed twice when the worker restarts #4426 - GitHub
I've increased processes on my virtual machine, and celery created worker with concurrency of 2(had 1 before).
Read more >Task gets executed twice when a view runs first time
As I can see in logs, celery worker is receiving this task twice: ... when I open the same url, there's only one...
Read more >Celery beat causes task to run twice - Google Groups
I have a celery setup inside a django app. Celery version is 3.1.23. Earlier I was running celery beat inside the worker using...
Read more >Release Notes — Airflow Documentation
Permission to view Airflow Configurations has been removed from User and Viewer role; Default [celery] worker_concurrency is changed to 16 ...
Read more >celery.app.task — Celery 5.2.7 documentation
Please note that this means the task may be executed twice if the worker crashes mid execution. The application default can be overridden...
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
level
controls creation of breadcrumbs (that is, writing them into a local “scrollback” buffer) andevent_level
controls creation of events. So yes, the INFO logs may appear in the event. However, we wipe breadcrumbs between celery tasks and between HTTP requests (depending on framework), and the buffer is per-thread. So they should be somewhat related to the crash.Glad to be of help!