Hello,
Currently, the exceptions take some time to be displayed because of the immediate reporting to Sentry service. How to report exceptions asynchronously (for example Redis or RabbitMQ) in laravel?
I鈥檓 using the latest "sentry/sentry-laravel": "^0.11.0"package in my Laravel 5.5 app.
Thanks,
Hey @masoudjahromi,
You are not using the latest version :) That would be ^1.0 (but do note there are breaking changes to the API if you are doing anything custom or setting user context, check out the new docs to see what changed: https://docs.sentry.io/platforms/php/laravel/).
There is no native way in Sentry to send exceptions via a queue, however version 1.0 of the Laravel SDK uses our new PHP SDK which does some "async" stuff to send the errors at the end of the request possibly already achieving what you need.
I would advise against sending exception asynchronous because if you queue is broken exceptions will never be sent which is not very helpful. Better to have a little slower 500 page than no data at all IMHO.
The closest Laravel offers here is using the terminate function of a http middleware. It only calls after the response has been fully prepared and has been streamed to the user. See https://laravel.com/docs/5.8/middleware#terminable-middleware
I wouldn't queue your errors. If something goes wrong, you want to be confident that the error get's reported and response time on error pages generally isn't that critical: you're anyway at a dead end.
Only way I would do this is by having an external script to laravel handle it. So you run the shell script from PHP but that is all, that way if your PHP app is super broken you still get the error.
The default of the new SDK used bu ^1.0 is to delay sending the events until after the request has ended or the php process is ending, so this should not be an issue anymore. If it is, let's open up a new issue to discuss the current situation 馃憤