Laravel queue job errors next to web errors
Install sentry/sentry-laravel and set SENTRY_LARAVEL_DSN=http://sentry@127.0.0.1:8000/1 in .env. When a queued job throws, its exception lands in Buggregator on the same page as your web errors. The breadcrumb "Processing queue job" names the job class, the queue, the connection and the attempt number.
Steps
1. Start Buggregator
docker run --pull always \
-p 127.0.0.1:8000:8000 \
ghcr.io/buggregator/server:latest2. Install the Sentry SDK
composer require sentry/sentry-laravelIn Laravel 11 and newer, let Sentry handle exceptions in bootstrap/app.php:
use Illuminate\Foundation\Configuration\Exceptions;
use Sentry\Laravel\Integration;
->withExceptions(function (Exceptions $exceptions) {
Integration::handles($exceptions);
})3. Set the DSN
One line in .env. The worker reads the same file. In Docker Compose, use the service name: http://sentry@buggregator:8000/1.
SENTRY_LARAVEL_DSN=http://sentry@127.0.0.1:8000/14. Restart the worker
A running worker keeps the config it started with.
php artisan queue:restart
php artisan queue:work5. Let a job fail
Dispatch a job that throws. Open http://127.0.0.1:8000. The exception shows its stack trace, and the breadcrumbs show the job it came from. Web errors and job errors sit in one list.
Why it works
Laravel reports the exception a job throws, and the Sentry SDK sends it like any other error. The SDK clears breadcrumbs when a job starts and adds one with the job's details, so the error shows only what happened in that job. It also sends the event as soon as the job fails, so a long-running worker does not hold it back.
Related tips
- Sentry
Laravel errors in Sentry's UI style, no Sentry account
Set SENTRY_LARAVEL_DSN to Buggregator. Each Laravel exception shows locally with its stack trace, request and breadcrumbs. No account, no limits.
- Sentry
See what happened right before the exception
Point your Laravel Sentry DSN at Buggregator. Each error shows its breadcrumbs, request, tags and stack trace on your laptop.
- Sentry
See a Laravel request's Sentry trace as a waterfall
Turn on Sentry tracing in Laravel and send it to Buggregator. Every span of a request shows on a timeline, and errors link to their trace.
- Logs
Laravel logs from web, queue and cron in one live view
Add a socket channel to config/logging.php and set LOG_CHANNEL=socket. Laravel logs from requests, queue workers and cron jobs appear live in Buggregator.
Checked on with Buggregator v2.13.0