@@ -2025,6 +2025,7 @@ void nr_php_observer_fcall_begin_late(zend_execute_data* execute_data, nrtime_t
20252025 * started transaction might actually obtain the same address as a
20262026 * transaction freed before.
20272027 */
2028+ (void )execute_data ;
20282029 if (nrunlikely (nr_txn_start_time (NRPRG (txn )) != txn_start_time )) {
20292030 nrl_verbosedebug (NRL_AGENT ,
20302031 "%s txn ended and/or started while in a wrapped function" ,
@@ -2033,17 +2034,6 @@ void nr_php_observer_fcall_begin_late(zend_execute_data* execute_data, nrtime_t
20332034 return ;
20342035 }
20352036
2036- if (false) {
2037- if (NR_OP_ARRAY -> scope ) {
2038- nr_txn_force_single_count (NRPRG (txn ), nr_txn_create_fn_supportability_metric (
2039- nr_php_op_array_function_name (NR_OP_ARRAY ),
2040- nr_php_class_entry_name (NR_OP_ARRAY -> scope )));
2041- } else {
2042- nr_txn_force_single_count (NRPRG (txn ), nr_txn_create_fn_supportability_metric (
2043- nr_php_op_array_function_name (NR_OP_ARRAY ),
2044- NULL ));
2045- }
2046- }
20472037 /*
20482038 * Check for, and handle, frameworks.
20492039 */
@@ -2227,7 +2217,11 @@ static void nr_php_instrument_func_end(NR_EXECUTE_PROTO, bool create_metric, boo
22272217 return ;
22282218}
22292219
2220+ #if ZEND_MODULE_API_NO >= ZEND_8_2_X_API_NO
2221+ static void nr_php_observer_fcall_begin_common (zend_execute_data * execute_data , bool call_late ) {
2222+ #else
22302223void nr_php_observer_fcall_begin (zend_execute_data * execute_data ) {
2224+ #endif
22312225 /*
22322226 * Instrument the function.
22332227 * This and any other needed helper functions will replace:
@@ -2266,55 +2260,24 @@ void nr_php_observer_fcall_begin(zend_execute_data* execute_data) {
22662260 return ;
22672261 }
22682262 nr_php_instrument_func_begin (NR_EXECUTE_ORIG_ARGS );
2269-
2270- return ;
2271- }
2272-
22732263#if ZEND_MODULE_API_NO >= ZEND_8_2_X_API_NO
2274- void nr_php_observer_fcall_begin_instrumented (zend_execute_data * execute_data ) {
2275- /*
2276- * Instrument the function.
2277- * This and any other needed helper functions will replace:
2278- * nr_php_execute_enabled
2279- * nr_php_execute
2280- * nr_php_execute_show
2281- */
2282- zval * func_return_value = NULL ;
2283- //if (execute_data->func && execute_data->func->common.function_name) {
2284- // printf("BEGIN %s", ZSTR_VAL(execute_data->func->common.function_name));
2285- //}
2286- if (nrunlikely (NULL == execute_data )) {
2287- return ;
2288- }
2289-
2290- NRPRG (php_cur_stack_depth ) += 1 ;
2291-
2292- if ((0 < ((int )NRINI (max_nesting_level )))
2293- && (NRPRG (php_cur_stack_depth ) >= (int )NRINI (max_nesting_level ))) {
2294- nr_php_max_nesting_level_reached ();
2264+ if (call_late ) {
2265+ nr_php_observer_fcall_begin_late (execute_data , nr_txn_start_time (NRPRG (txn )));
22952266 }
2296-
2297- if (nrunlikely (0 == nr_php_recording ())) {
2298- return ;
2299- }
2300-
2301- int show_executes = NR_PHP_PROCESS_GLOBALS (special_flags ).show_executes ;
2302-
2303- if (nrunlikely (show_executes )) {
2304- nr_php_show_exec (NR_EXECUTE_ORIG_ARGS );
2305- }
2306- if (NULL == NRPRG (txn )) {
2307- return ;
2308- }
2309- nr_php_instrument_func_begin (NR_EXECUTE_ORIG_ARGS );
2310- nr_php_observer_fcall_begin_late (execute_data , nr_txn_start_time (NRPRG (txn )));
2267+ #endif
23112268
23122269 return ;
23132270}
2314- #endif
23152271
2272+ #if ZEND_MODULE_API_NO >= ZEND_8_2_X_API_NO
2273+ static void nr_php_observer_fcall_end_common (zend_execute_data * execute_data ,
2274+ zval * func_return_value ,
2275+ bool create_metric ,
2276+ bool end_segment ) {
2277+ #else
23162278void nr_php_observer_fcall_end (zend_execute_data * execute_data ,
23172279 zval * func_return_value ) {
2280+ #endif
23182281 /*
23192282 * Instrument the function.
23202283 * This and any other needed helper functions will replace:
@@ -2341,7 +2304,7 @@ void nr_php_observer_fcall_end(zend_execute_data* execute_data,
23412304 }
23422305
23432306#if ZEND_MODULE_API_NO >= ZEND_8_2_X_API_NO
2344- nr_php_instrument_func_end (NR_EXECUTE_ORIG_ARGS , false, true );
2307+ nr_php_instrument_func_end (NR_EXECUTE_ORIG_ARGS , create_metric , end_segment );
23452308#else
23462309 nr_php_instrument_func_end (NR_EXECUTE_ORIG_ARGS );
23472310#endif
@@ -2353,45 +2316,29 @@ void nr_php_observer_fcall_end(zend_execute_data* execute_data,
23532316}
23542317
23552318#if ZEND_MODULE_API_NO >= ZEND_8_2_X_API_NO
2319+ void nr_php_observer_fcall_begin (zend_execute_data * execute_data ) {
2320+ nr_php_observer_fcall_begin_common (execute_data , false);
2321+ }
2322+ void nr_php_observer_fcall_begin_instrumented (zend_execute_data * execute_data ) {
2323+ nr_php_observer_fcall_begin_common (execute_data , true);
2324+ }
2325+ void nr_php_observer_fcall_end (zend_execute_data * execute_data ,
2326+ zval * func_return_value ) {
2327+ nr_php_observer_fcall_end_common (execute_data , func_return_value , false, true);
2328+ }
2329+ void nr_php_observer_fcall_end_create_metric (zend_execute_data * execute_data ,
2330+ zval * func_return_value ) {
2331+ nr_php_observer_fcall_end_common (execute_data , func_return_value , true, true);
2332+ }
2333+ void nr_php_observer_fcall_end_keep_segment (zend_execute_data * execute_data ,
2334+ zval * func_return_value ) {
2335+ nr_php_observer_fcall_end_common (execute_data , func_return_value , false, false);
2336+ }
2337+
23562338// These empty functions (rather than NULL) are used to know if instrumentation
23572339// has been added This is needed because the process for adding instrumentation
23582340// with a transient wrapper differs depending on if the function has been
23592341// previously called. These will only be used when tt_detail is 0.
2360- void nr_php_observer_fcall_end_keep_segment (zend_execute_data * execute_data ,
2361- zval * func_return_value ) {
2362- /*
2363- * Instrument the function.
2364- * This and any other needed helper functions will replace:
2365- * nr_php_execute_enabled
2366- * nr_php_execute
2367- * nr_php_execute_show
2368- */
2369- if (nrunlikely (NULL == execute_data )) {
2370- return ;
2371- }
2372- //if (execute_data->func && execute_data->func->common.function_name) {
2373- // printf("END %s\n", ZSTR_VAL(execute_data->func->common.function_name));
2374- //}
2375-
2376- if (nrlikely (1 == nr_php_recording ())) {
2377- int show_executes_return
2378- = NR_PHP_PROCESS_GLOBALS (special_flags ).show_execute_returns ;
2379-
2380- if (nrunlikely (show_executes_return )) {
2381- nrl_verbosedebug (NRL_AGENT ,
2382- "Stack depth: %d before OAPI function exiting via %s" ,
2383- NRPRG (php_cur_stack_depth ), __func__ );
2384- nr_php_show_exec_return (NR_EXECUTE_ORIG_ARGS TSRMLS_CC );
2385- }
2386-
2387- nr_php_instrument_func_end (NR_EXECUTE_ORIG_ARGS , false, false);
2388- }
2389-
2390- NRPRG (php_cur_stack_depth ) -= 1 ;
2391-
2392- return ;
2393- }
2394-
23952342void nr_php_observer_empty_fcall_begin (zend_execute_data * execute_data ) {
23962343 (void )execute_data ;
23972344}
@@ -2402,37 +2349,6 @@ void nr_php_observer_empty_fcall_end(zend_execute_data* execute_data,
24022349 (void )func_return_value ;
24032350}
24042351
2405- void nr_php_observer_fcall_end_create_metric (zend_execute_data * execute_data ,
2406- zval * func_return_value ) {
2407- /*
2408- * Instrument the function.
2409- * This and any other needed helper functions will replace:
2410- * nr_php_execute_enabled
2411- * nr_php_execute
2412- * nr_php_execute_show
2413- */
2414- if (nrunlikely (NULL == execute_data )) {
2415- return ;
2416- }
2417- //if (execute_data->func && execute_data->func->common.function_name) {
2418- // printf("END %s\n", ZSTR_VAL(execute_data->func->common.function_name));
2419- //}
2420-
2421- if (nrlikely (1 == nr_php_recording ())) {
2422- int show_executes_return
2423- = NR_PHP_PROCESS_GLOBALS (special_flags ).show_execute_returns ;
2424-
2425- if (nrunlikely (show_executes_return )) {
2426- nr_php_show_exec_return (NR_EXECUTE_ORIG_ARGS TSRMLS_CC );
2427- }
2428-
2429- nr_php_instrument_func_end (NR_EXECUTE_ORIG_ARGS , true, true);
2430- }
2431-
2432- NRPRG (php_cur_stack_depth ) -= 1 ;
2433-
2434- return ;
2435- }
24362352#endif
24372353
24382354#endif
0 commit comments