77use Illuminate \Routing \Route ;
88use Illuminate \Log \Events \MessageLogged ;
99use Illuminate \Auth \Events \Authenticated ;
10+ use Illuminate \Queue \Events \JobProcessed ;
11+ use Illuminate \Queue \Events \JobProcessing ;
1012use Illuminate \Routing \Events \RouteMatched ;
1113use Illuminate \Contracts \Events \Dispatcher ;
1214use Illuminate \Database \Events \QueryExecuted ;
@@ -27,6 +29,9 @@ class SentryLaravelEventHandler
2729
2830 'illuminate.log ' => 'log ' , // Until Laravel 5.3
2931 'Illuminate\Log\Events\MessageLogged ' => 'messageLogged ' , // Since Laravel 5.4
32+
33+ 'Illuminate\Queue\Events\JobProcessed ' => 'queueJobProcessed ' , // since Laravel 5.2
34+ 'Illuminate\Queue\Events\JobProcessing ' => 'queueJobProcessing ' , // since Laravel 5.2
3035 );
3136
3237 /**
@@ -234,4 +239,42 @@ protected function authenticatedHandler(Authenticated $event)
234239 'id ' => $ event ->user ->getAuthIdentifier (),
235240 ));
236241 }
242+
243+ /**
244+ * Since Laravel 5.2
245+ *
246+ * @param \Illuminate\Queue\Events\JobProcessed $event
247+ */
248+ protected function queueJobProcessedHandler (JobProcessed $ event )
249+ {
250+ $ this ->client ->sendUnsentErrors ();
251+
252+ $ this ->client ->breadcrumbs ->reset ();
253+ }
254+
255+ /**
256+ * Since Laravel 5.2
257+ *
258+ * @param \Illuminate\Queue\Events\JobProcessing $event
259+ */
260+ protected function queueJobProcessingHandler (JobProcessing $ event )
261+ {
262+ $ job = [
263+ 'job ' => $ event ->job ->getName (),
264+ 'queue ' => $ event ->job ->getQueue (),
265+ 'attempts ' => $ event ->job ->attempts (),
266+ 'connection ' => $ event ->connectionName ,
267+ ];
268+
269+ // Resolve name exists only from Laravel 5.3+
270+ if (method_exists ($ event ->job , 'resolveName ' )) {
271+ $ job ['resolved ' ] = $ event ->job ->resolveName ();
272+ }
273+
274+ $ this ->client ->breadcrumbs ->record ([
275+ 'category ' => 'queue.job ' ,
276+ 'message ' => 'Processing queue job ' ,
277+ 'data ' => $ job ,
278+ ]);
279+ }
237280}
0 commit comments