14
14
use Illuminate \Http \Client \Events as HttpClientEvents ;
15
15
use Illuminate \Http \Request ;
16
16
use Illuminate \Log \Events as LogEvents ;
17
- use Illuminate \Queue \Events as QueueEvents ;
18
17
use Illuminate \Routing \Events as RoutingEvents ;
19
18
use Laravel \Octane \Events as Octane ;
20
19
use Laravel \Sanctum \Events as Sanctum ;
@@ -55,18 +54,6 @@ class EventHandler
55
54
Sanctum \TokenAuthenticated::class => 'sanctumTokenAuthenticated ' , // Since Sanctum 2.13
56
55
];
57
56
58
- /**
59
- * Map queue event handlers to events.
60
- *
61
- * @var array
62
- */
63
- protected static $ queueEventHandlerMap = [
64
- QueueEvents \JobProcessed::class => 'queueJobProcessed ' ,
65
- QueueEvents \JobProcessing::class => 'queueJobProcessing ' ,
66
- QueueEvents \WorkerStopping::class => 'queueWorkerStopping ' ,
67
- QueueEvents \JobExceptionOccurred::class => 'queueJobExceptionOccurred ' ,
68
- ];
69
-
70
57
/**
71
58
* Map Octane event handlers to events.
72
59
*
@@ -114,13 +101,6 @@ class EventHandler
114
101
*/
115
102
private $ recordLaravelLogs ;
116
103
117
- /**
118
- * Indicates if we should add queue info to the breadcrumbs.
119
- *
120
- * @var bool
121
- */
122
- private $ recordQueueInfo ;
123
-
124
104
/**
125
105
* Indicates if we should add command info to the breadcrumbs.
126
106
*
@@ -149,13 +129,6 @@ class EventHandler
149
129
*/
150
130
private $ recordHttpClientRequests ;
151
131
152
- /**
153
- * Indicates if we pushed a scope for the queue.
154
- *
155
- * @var int
156
- */
157
- private $ pushedQueueScopeCount = 0 ;
158
-
159
132
/**
160
133
* Indicates if we pushed a scope for Octane.
161
134
*
@@ -176,7 +149,6 @@ public function __construct(Container $container, array $config)
176
149
$ this ->recordSqlQueries = ($ config ['breadcrumbs.sql_queries ' ] ?? $ config ['breadcrumbs ' ]['sql_queries ' ] ?? true ) === true ;
177
150
$ this ->recordSqlBindings = ($ config ['breadcrumbs.sql_bindings ' ] ?? $ config ['breadcrumbs ' ]['sql_bindings ' ] ?? false ) === true ;
178
151
$ this ->recordLaravelLogs = ($ config ['breadcrumbs.logs ' ] ?? $ config ['breadcrumbs ' ]['logs ' ] ?? true ) === true ;
179
- $ this ->recordQueueInfo = ($ config ['breadcrumbs.queue_info ' ] ?? $ config ['breadcrumbs ' ]['queue_info ' ] ?? true ) === true ;
180
152
$ this ->recordCommandInfo = ($ config ['breadcrumbs.command_info ' ] ?? $ config ['breadcrumbs ' ]['command_info ' ] ?? true ) === true ;
181
153
$ this ->recordOctaneTickInfo = ($ config ['breadcrumbs.octane_tick_info ' ] ?? $ config ['breadcrumbs ' ]['octane_tick_info ' ] ?? true ) === true ;
182
154
$ this ->recordOctaneTaskInfo = ($ config ['breadcrumbs.octane_task_info ' ] ?? $ config ['breadcrumbs ' ]['octane_task_info ' ] ?? true ) === true ;
@@ -204,7 +176,7 @@ public function subscribeAuthEvents(Dispatcher $dispatcher): void
204
176
}
205
177
206
178
/**
207
- * Attach all queue event handlers.
179
+ * Attach all Octane event handlers.
208
180
*/
209
181
public function subscribeOctaneEvents (Dispatcher $ dispatcher ): void
210
182
{
@@ -213,16 +185,6 @@ public function subscribeOctaneEvents(Dispatcher $dispatcher): void
213
185
}
214
186
}
215
187
216
- /**
217
- * Attach all queue event handlers.
218
- */
219
- public function subscribeQueueEvents (Dispatcher $ dispatcher ): void
220
- {
221
- foreach (static ::$ queueEventHandlerMap as $ eventName => $ handler ) {
222
- $ dispatcher ->listen ($ eventName , [$ this , $ handler ]);
223
- }
224
- }
225
-
226
188
/**
227
189
* Pass through the event and capture any errors.
228
190
*
@@ -407,57 +369,6 @@ private function configureUserScopeFromModel($authUser): void
407
369
});
408
370
}
409
371
410
- protected function queueJobProcessingHandler (QueueEvents \JobProcessing $ event ): void
411
- {
412
- $ this ->cleanupScopeForTaskWithinLongRunningProcessWhen ($ this ->pushedQueueScopeCount > 0 );
413
-
414
- $ this ->prepareScopeForTaskWithinLongRunningProcess ();
415
-
416
- ++$ this ->pushedQueueScopeCount ;
417
-
418
- if (!$ this ->recordQueueInfo ) {
419
- return ;
420
- }
421
-
422
- $ job = [
423
- 'job ' => $ event ->job ->getName (),
424
- 'queue ' => $ event ->job ->getQueue (),
425
- 'attempts ' => $ event ->job ->attempts (),
426
- 'connection ' => $ event ->connectionName ,
427
- ];
428
-
429
- // Resolve name exists only from Laravel 5.3+
430
- if (method_exists ($ event ->job , 'resolveName ' )) {
431
- $ job ['resolved ' ] = $ event ->job ->resolveName ();
432
- }
433
-
434
- Integration::addBreadcrumb (new Breadcrumb (
435
- Breadcrumb::LEVEL_INFO ,
436
- Breadcrumb::TYPE_DEFAULT ,
437
- 'queue.job ' ,
438
- 'Processing queue job ' ,
439
- $ job
440
- ));
441
- }
442
-
443
- protected function queueJobExceptionOccurredHandler (QueueEvents \JobExceptionOccurred $ event ): void
444
- {
445
- $ this ->afterTaskWithinLongRunningProcess ();
446
- }
447
-
448
- protected function queueJobProcessedHandler (QueueEvents \JobProcessed $ event ): void
449
- {
450
- $ this ->cleanupScopeForTaskWithinLongRunningProcessWhen ($ this ->pushedQueueScopeCount > 0 );
451
-
452
- $ this ->afterTaskWithinLongRunningProcess ();
453
- }
454
-
455
- protected function queueWorkerStoppingHandler (QueueEvents \WorkerStopping $ event ): void
456
- {
457
- // Flush any and all events that were possibly generated by queue jobs
458
- Integration::flushEvents ();
459
- }
460
-
461
372
protected function commandStartingHandler (ConsoleEvents \CommandStarting $ event ): void
462
373
{
463
374
if ($ event ->command ) {
@@ -630,7 +541,6 @@ private function logLevelToBreadcrumbLevel(string $level): string
630
541
*/
631
542
private function afterTaskWithinLongRunningProcess (): void
632
543
{
633
- // Flush any and all events that were possibly generated by queue jobs
634
544
Integration::flushEvents ();
635
545
}
636
546
0 commit comments