Skip to content

Commit 8e82269

Browse files
authored
feat(agent): properly handle idle laravel queue workers (#1126)
This PR ensures idle laravel queue workers are properly handled by ending the current transaction and starting a new one.
1 parent 492b5b4 commit 8e82269

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

agent/fw_laravel.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1208,6 +1208,19 @@ NR_PHP_WRAPPER(nr_laravel_horizon_end_txn) {
12081208
}
12091209
NR_PHP_WRAPPER_END
12101210

1211+
/*
1212+
* End transaction for idle laravel queue workers and then start
1213+
* a new transaction.
1214+
*/
1215+
NR_PHP_WRAPPER(nr_laravel_queue_restart_transaction) {
1216+
NR_UNUSED_SPECIALFN;
1217+
(void)wraprec;
1218+
1219+
nr_php_txn_end(1, 0 TSRMLS_CC);
1220+
nr_php_txn_begin(NULL, NULL TSRMLS_CC);
1221+
}
1222+
NR_PHP_WRAPPER_END
1223+
12111224
void nr_laravel_enable(TSRMLS_D) {
12121225
/*
12131226
* We set the path to 'unknown' to prevent having to name routing errors.
@@ -1259,6 +1272,15 @@ void nr_laravel_enable(TSRMLS_D) {
12591272
nr_php_wrap_user_function_before_after_clean(
12601273
NR_PSTR("Laravel\\Horizon\\Console\\SupervisorCommand::handle"),
12611274
nr_laravel_horizon_end_txn, NULL, NULL);
1275+
1276+
/*
1277+
* The following function has been added to ensure idle laravel queue workers
1278+
* are properly handled by ending the current transaction and starting a new
1279+
* one.
1280+
*/
1281+
nr_php_wrap_user_function_before_after_clean(
1282+
NR_PSTR("Illuminate\\Queue\\Worker::daemonShouldRun"),
1283+
nr_laravel_queue_restart_transaction, NULL, NULL);
12621284
#else
12631285
nr_php_wrap_user_function(NR_PSTR("Symfony\\Component\\Console\\Application::doRun"),
12641286
nr_laravel_console_application_dorun TSRMLS_CC);

0 commit comments

Comments
 (0)