Skip to content

Commit 1269a02

Browse files
committed
try: cleanup wrappers
1 parent 2357c1c commit 1269a02

File tree

1 file changed

+30
-7
lines changed

1 file changed

+30
-7
lines changed

agent/fw_laravel_queue.c

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -387,16 +387,25 @@ NR_PHP_WRAPPER(nr_laravel_queue_worker_after) {
387387
}
388388

389389
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);
397391
}
398392
NR_PHP_WRAPPER_END
399393

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+
400409
#else
401410
/*
402411
* Purpose : Extract the actual job name from a job that used CallQueuedHandler
@@ -960,6 +969,20 @@ void nr_laravel_queue_enable(TSRMLS_D) {
960969
NR_PSTR("Illuminate\\Queue\\SyncQueue::raiseBeforeJobEvent"),
961970
nr_laravel_queue_worker_raiseBeforeJobEvent_before, NULL, NULL);
962971

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+
963986
#else
964987

965988
/*

0 commit comments

Comments
 (0)