Skip to content

Commit 2357c1c

Browse files
committed
fix: give basic name to queue process throwaway txn
In case the queue process txn that we keep open so we caninstrument actually becomes a real txn, name it.
1 parent 437141a commit 2357c1c

File tree

1 file changed

+10
-42
lines changed

1 file changed

+10
-42
lines changed

agent/fw_laravel_queue.c

Lines changed: 10 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -361,9 +361,9 @@ NR_PHP_WRAPPER(nr_laravel_queue_worker_after) {
361361
* Illuminate\\Queue\\SyncQueue::executeJob is called again
362362
*/
363363

364-
if (NULL != auto_segment->error) {
365-
/* An exception occurred we need to record it on the txn if it isn't already
366-
* there. */
364+
if (NULL == nr_php_get_return_value(NR_EXECUTE_ORIG_ARGS)) {
365+
/* An exception occurred and we need to record it on the txn if it isn't
366+
* already there. */
367367
if (NULL == NRPRG(txn)->error) {
368368
/* Since we are ending this txn within the wrapper, and we know it has an
369369
error, apply it to the txn; otherwise, the
@@ -387,28 +387,13 @@ NR_PHP_WRAPPER(nr_laravel_queue_worker_after) {
387387
}
388388

389389
nr_php_txn_end(0, 0 TSRMLS_CC);
390-
nr_php_txn_begin(NULL, NULL TSRMLS_CC);
391-
}
392-
NR_PHP_WRAPPER_END
393-
394-
/*
395-
* Handles:
396-
* Illuminate\\Queue\\Worker::process
397-
* Illuminate\\Queue\\SyncQueue::executeJob
398-
*/
399-
400-
NR_PHP_WRAPPER(nr_laravel_queue_worker_stop_after) {
401-
NR_UNUSED_SPECIALFN;
402-
(void)wraprec;
403-
NR_PHP_WRAPPER_REQUIRE_FRAMEWORK(NR_FW_LARAVEL);
404-
/*
405-
* Anytime the worker is considering whether to stop or not (or actually
406-
* stopping), we can ignore everything that's happened previously (sleeping
407-
* etc) that is non job processing related and avoid a useless txn.
408-
*/
409-
410-
nr_php_txn_end(0, 0 TSRMLS_CC);
411-
nr_php_txn_begin(NULL, NULL 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+
}
412397
}
413398
NR_PHP_WRAPPER_END
414399

@@ -975,23 +960,6 @@ void nr_laravel_queue_enable(TSRMLS_D) {
975960
NR_PSTR("Illuminate\\Queue\\SyncQueue::raiseBeforeJobEvent"),
976961
nr_laravel_queue_worker_raiseBeforeJobEvent_before, NULL, NULL);
977962

978-
/*
979-
* Additional cleanup so we don't help prevent a useless excess txn after the
980-
* worker ends. Anytime the worker is questioning whether it should stop or is
981-
* going to stop, we can end the txn.
982-
*/
983-
if (0) {
984-
nr_php_wrap_user_function_before_after_clean(
985-
NR_PSTR("Illuminate\\Queue\\Worker::stopIfNecessary"), NULL,
986-
nr_laravel_queue_worker_stop_after, NULL);
987-
nr_php_wrap_user_function_before_after_clean(
988-
NR_PSTR("Illuminate\\Queue\\Worker::stopWorkerIfLostConnection"), NULL,
989-
nr_laravel_queue_worker_stop_after, NULL);
990-
nr_php_wrap_user_function_before_after_clean(
991-
NR_PSTR("Illuminate\\Queue\\Worker::stop"), NULL,
992-
nr_laravel_queue_worker_stop_after, NULL);
993-
}
994-
995963
#else
996964

997965
/*

0 commit comments

Comments
 (0)