Skip to content

Commit 7bc6138

Browse files
committed
record frankenphp worker loop iteration as background transaction
1 parent efb1f2d commit 7bc6138

2 files changed

Lines changed: 11 additions & 6 deletions

File tree

agent/php_frankenphp.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,6 @@ void nr_php_frankenphp_handle_request(INTERNAL_FUNCTION_PARAMETERS) {
3737
zend_function* zf;
3838
nruserfn_t* wr = NULL;
3939

40-
// Always end current transaction started when worker was started
41-
nr_txn_set_path("frankenphp_handle_request", NRPRG(txn), "frankenphp/worker",
42-
NR_PATH_TYPE_CUSTOM, NR_OK_TO_OVERWRITE);
43-
nr_txn_set_as_background_job(NRPRG(txn), "frankenphp worker");
44-
nr_php_txn_end(0, 0);
45-
4640
zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "z",
4741
&function);
4842
zf = nr_php_zval_to_function(function);

agent/php_internal_instrument.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3123,10 +3123,21 @@ NR_INNER_WRAPPER(exception_common) {
31233123
NR_INNER_WRAPPER(frankenphp_handle_request) {
31243124
nrl_verbosedebug(NRL_INIT, "frankenphp_handle_request started");
31253125

3126+
// End the worker transaction
3127+
nr_txn_set_path("frankenphp_handle_request", NRPRG(txn), "frankenphp/worker/bootstrap",
3128+
NR_PATH_TYPE_CUSTOM, NR_NOT_OK_TO_OVERWRITE); // this will not overwrite the 'loop' path
3129+
nr_txn_set_as_background_job(NRPRG(txn), "frankenphp worker");
3130+
nr_php_txn_end(0, 0);
3131+
31263132
nr_php_frankenphp_handle_request(INTERNAL_FUNCTION_PARAM_PASSTHRU);
31273133

31283134
// Let frankenphp take over
31293135
nr_wrapper->oldhandler(INTERNAL_FUNCTION_PARAM_PASSTHRU);
3136+
3137+
// Start a new transaction for worker loop
3138+
nr_php_txn_begin(0, 0);
3139+
nr_txn_set_path("frankenphp_handle_request", NRPRG(txn), "frankenphp/worker/loop",
3140+
NR_PATH_TYPE_CUSTOM, NR_NOT_OK_TO_OVERWRITE);
31303141
nrl_verbosedebug(NRL_INIT, "frankenphp_handle_request done");
31313142
}
31323143
#endif

0 commit comments

Comments
 (0)