Add support for cron jobs in ARQ integration#2088
Add support for cron jobs in ARQ integration#2088antonpirker merged 6 commits intogetsentry:masterfrom
Conversation
| assert error_event["exception"]["values"][0]["mechanism"]["type"] == "arq" | ||
| loop = asyncio.get_event_loop() | ||
| task = loop.create_task(worker.async_run()) | ||
| await asyncio.sleep(1) |
There was a problem hiding this comment.
This is needed because the cron job automatically execute after the worker starts.
There's no way to actually wait for a cron job to finish other than adding some delay before asserting results.
|
Hey @lewazo ! |
|
This pull request 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 "A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀 |
|
ping |
|
This pull request 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 "A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀 |
antonpirker
left a comment
There was a problem hiding this comment.
Nice work!
Looks good to me, and does what it should!
|
Btw @lewazo and @iam-abbas Sentry has now a "Crons" feature, where cron jobs can submit their config (when it should run) on creation of a cron job and then can have check ins on each run (and on each success and failure) and then one has a nice UI in Sentry to see if the crons are running on time and if there are errors. Here is part of the implementation in Celery: https://github.com/getsentry/sentry-python/blob/master/sentry_sdk/integrations/celery.py#L500-L518 Maybe you want to add this too for ARQ? |
|
Thanks @antonpirker that looks like a nice feature indeed and sounds perfect for this integration. I'll reserve some time to take a look at implementing it for ARQ |
This adds support for logging exceptions that occurs in ARQ cron jobs to Sentry.
Previously, only the tasks defined in the functions argument of the ARQ Worker Settings class were supported. Cron jobs were being ignored.
Since Cron Jobs run automatically by the
workerobject, we need to patch theworkerinstead of thefuncfunction that was previously patched.