I have Sentry.io set-up on my Laravel project. I'm also using Queues.
I was wondering if it was possible to send failed queues to Sentry? As they don't automatically send when they fail.
I have Sentry.io set-up on my Laravel project. I'm also using Queues.
I was wondering if it was possible to send failed queues to Sentry? As they don't automatically send when they fail.
By failed queues I guess you mean failed jobs, for that you just need to implement the failed()
method inside the job:
/**
* Handle a job failure.
*
* @return void
*/
public function failed(\Exception $exception)
{
// Send exception data to sentry.io
// It should catch it by default since it throws an exception
// But you can force a report manually
app('sentry')->captureException($exception);
}
Check how to deal with failed jobs in Laravel documentation.
If you added the following snippet to your error handler (as described here), all uncatched exceptions (also when thrown in queue jobs) are catched as long as they pass the ->shouldReport()
check.
if (app()->bound('sentry') && $this->shouldReport($exception)) {
app('sentry')->captureException($exception);
}