Skip to content

Commit 506563c

Browse files
Merge pull request #1133 from newrelic/dev
Release 12.2
2 parents 1e5fa6d + cd4e412 commit 506563c

23 files changed

Lines changed: 1119 additions & 94 deletions

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
12.1.0
1+
12.2.0

agent/Makefile.frag

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ TEST_BINARIES = \
8787
tests/test_environment \
8888
tests/test_fw_codeigniter \
8989
tests/test_fw_drupal \
90+
tests/test_fw_laravel_queue \
9091
tests/test_fw_support \
9192
tests/test_fw_wordpress \
9293
tests/test_globals \

agent/fw_laravel.c

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1193,6 +1193,45 @@ static nr_status_t nr_laravel_should_assign_generic_path(const nrtxn_t* txn,
11931193
return NR_FAILURE;
11941194
}
11951195

1196+
/*
1197+
* Ensure that the transaction is properly stopped when Laravel Horizon is being
1198+
* used by wrapping the handle method of the HorizonCommand and
1199+
* SupervisorCommand class.
1200+
*/
1201+
NR_PHP_WRAPPER(nr_laravel_horizon_end_txn) {
1202+
NR_UNUSED_SPECIALFN;
1203+
(void)wraprec;
1204+
1205+
nr_php_txn_end(1, 0 TSRMLS_CC);
1206+
1207+
nrl_verbosedebug(NRL_FRAMEWORK, "Ending Laravel Horizon Transaction");
1208+
}
1209+
NR_PHP_WRAPPER_END
1210+
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+
1224+
/*
1225+
* Set global flag that checks if Laravel Horizon is being used to true.
1226+
*/
1227+
NR_PHP_WRAPPER(nr_laravel_horizon_is_used) {
1228+
NR_UNUSED_SPECIALFN;
1229+
(void)wraprec;
1230+
1231+
NR_PHP_PROCESS_GLOBALS(laravel_horizon_worker_used) = true;
1232+
}
1233+
NR_PHP_WRAPPER_END
1234+
11961235
void nr_laravel_enable(TSRMLS_D) {
11971236
/*
11981237
* We set the path to 'unknown' to prevent having to name routing errors.
@@ -1231,6 +1270,33 @@ void nr_laravel_enable(TSRMLS_D) {
12311270
nr_php_wrap_user_function_before_after_clean(
12321271
NR_PSTR("Symfony\\Component\\Console\\Application::doRun"),
12331272
nr_laravel_console_application_dorun, NULL, NULL);
1273+
1274+
/*
1275+
* The following functions have been added to ensure that the transaction
1276+
* is properly stopped when Laravel Horizon is being used. This is
1277+
* accomplished by wrapping the handle method of the HorizonCommand class and
1278+
* the SupervisorCommand class.
1279+
*/
1280+
nr_php_wrap_user_function_before_after_clean(
1281+
NR_PSTR("Laravel\\Horizon\\Console\\HorizonCommand::handle"),
1282+
nr_laravel_horizon_end_txn, NULL, NULL);
1283+
nr_php_wrap_user_function_before_after_clean(
1284+
NR_PSTR("Laravel\\Horizon\\Console\\SupervisorCommand::handle"),
1285+
nr_laravel_horizon_end_txn, NULL, NULL);
1286+
/*
1287+
* Check if Laravel Horizon is being used.
1288+
*/
1289+
nr_php_wrap_user_function_before_after_clean(
1290+
NR_PSTR("Laravel\\Horizon\\Console\\WorkCommand::handle"),
1291+
nr_laravel_horizon_is_used, NULL, NULL);
1292+
/*
1293+
* The following function has been added to ensure idle laravel queue workers
1294+
* are properly handled by ending the current transaction and starting a new
1295+
* one.
1296+
*/
1297+
nr_php_wrap_user_function_before_after_clean(
1298+
NR_PSTR("Illuminate\\Queue\\Worker::daemonShouldRun"),
1299+
nr_laravel_queue_restart_transaction, NULL, NULL);
12341300
#else
12351301
nr_php_wrap_user_function(NR_PSTR("Symfony\\Component\\Console\\Application::doRun"),
12361302
nr_laravel_console_application_dorun TSRMLS_CC);

0 commit comments

Comments
 (0)