@@ -387,16 +387,25 @@ NR_PHP_WRAPPER(nr_laravel_queue_worker_after) {
387
387
}
388
388
389
389
nr_php_txn_end (0 , 0 TSRMLS_CC );
390
- /* Let's give it some rudimentary name so it won't be unknown in case we exit
391
- * and this becomes a txn.*/
392
- if (NR_SUCCESS == nr_php_txn_begin (NULL , NULL TSRMLS_CC )) {
393
- nr_txn_set_as_background_job (NRPRG (txn ), "Laravel queue worker process" );
394
- nr_txn_set_path ("Laravel" , NRPRG (txn ), "Laravel queue worker process" ,
395
- NR_PATH_TYPE_CUSTOM , NR_OK_TO_OVERWRITE );
396
- }
390
+ nr_php_txn_begin (NULL , NULL TSRMLS_CC );
397
391
}
398
392
NR_PHP_WRAPPER_END
399
393
394
+ NR_PHP_WRAPPER (nr_laravel_queue_worker_stop_after ) {
395
+ NR_UNUSED_SPECIALFN ;
396
+ (void )wraprec ;
397
+ NR_PHP_WRAPPER_REQUIRE_FRAMEWORK (NR_FW_LARAVEL );
398
+ /*
399
+ * Anytime the worker is considering whether to stop or not (or actually stopping),
400
+ * we can ignore everything that's happened previously (sleeping etc) that is non job processing related and avoid a useless txn.
401
+ */
402
+
403
+
404
+ nr_php_txn_end (0 , 0 TSRMLS_CC );
405
+ nr_php_txn_begin (NULL , NULL TSRMLS_CC );
406
+ }
407
+ NR_PHP_WRAPPER_END
408
+
400
409
#else
401
410
/*
402
411
* Purpose : Extract the actual job name from a job that used CallQueuedHandler
@@ -960,6 +969,20 @@ void nr_laravel_queue_enable(TSRMLS_D) {
960
969
NR_PSTR ("Illuminate\\Queue\\SyncQueue::raiseBeforeJobEvent" ),
961
970
nr_laravel_queue_worker_raiseBeforeJobEvent_before , NULL , NULL );
962
971
972
+ /*
973
+ * Additional cleanup so we don't help prevent a useless excess txn after the worker ends.
974
+ * Anytime the worker is questioning whether it should stop or is going to stop, we can end the txn.
975
+ */
976
+ nr_php_wrap_user_function_before_after_clean (
977
+ NR_PSTR ("Illuminate\\Queue\\Worker::stopIfNecessary" ),
978
+ NULL , nr_laravel_queue_worker_stop_after , NULL );
979
+ nr_php_wrap_user_function_before_after_clean (
980
+ NR_PSTR ("Illuminate\\Queue\\Worker::stopWorkerIfLostConnection" ),
981
+ NULL , nr_laravel_queue_worker_stop_after , NULL );
982
+ nr_php_wrap_user_function_before_after_clean (
983
+ NR_PSTR ("Illuminate\\Queue\\Worker::stop" ),
984
+ NULL , nr_laravel_queue_worker_stop_after , NULL );
985
+
963
986
#else
964
987
965
988
/*
0 commit comments