Skip to content

Commit f01406b

Browse files
ZNeumannlavarou
authored andcommitted
add metric for ini instrumented
1 parent 1a9b953 commit f01406b

File tree

4 files changed

+26
-13
lines changed

4 files changed

+26
-13
lines changed

agent/php_execute.c

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1991,7 +1991,7 @@ static void nr_php_instrument_func_begin(NR_EXECUTE_PROTO) {
19911991
}
19921992

19931993
#if ZEND_MODULE_API_NO >= ZEND_8_2_X_API_NO
1994-
void nr_php_observer_fcall_begin_late(zend_execute_data* execute_data, nrtime_t txn_start_time) {
1994+
void nr_php_observer_fcall_begin_late(zend_execute_data* execute_data, nrtime_t txn_start_time, bool name_transaction) {
19951995
/*
19961996
* During nr_zend_call_oapi_special_before, the transaction may have been
19971997
* ended and/or a new transaction may have started. To detect this, we
@@ -2014,12 +2014,14 @@ void nr_php_observer_fcall_begin_late(zend_execute_data* execute_data, nrtime_t
20142014
/*
20152015
* Check for, and handle, frameworks.
20162016
*/
2017-
//if (wraprec->is_names_wt_simple) {
2017+
if (name_transaction) {
20182018

2019-
// nr_txn_name_from_function(NRPRG(txn),
2020-
// nr_php_op_array_function_name(NR_OP_ARRAY),
2021-
// nr_php_class_entry_name(NR_OP_ARRAY->scope));
2022-
//}
2019+
nr_txn_name_from_function(NRPRG(txn),
2020+
nr_php_op_array_function_name(NR_OP_ARRAY),
2021+
NR_OP_ARRAY->scope ?
2022+
nr_php_class_entry_name(NR_OP_ARRAY->scope) :
2023+
NULL);
2024+
}
20232025
}
20242026
#endif
20252027

@@ -2198,7 +2200,7 @@ static void nr_php_instrument_func_end(NR_EXECUTE_PROTO, bool create_metric, boo
21982200
}
21992201

22002202
#if ZEND_MODULE_API_NO >= ZEND_8_2_X_API_NO
2201-
static void nr_php_observer_fcall_begin_common(zend_execute_data* execute_data, bool call_late) {
2203+
static void nr_php_observer_fcall_begin_common(zend_execute_data* execute_data, bool call_late, bool name_transaction) {
22022204
#else
22032205
void nr_php_observer_fcall_begin(zend_execute_data* execute_data) {
22042206
#endif
@@ -2242,7 +2244,7 @@ void nr_php_observer_fcall_begin(zend_execute_data* execute_data) {
22422244
nr_php_instrument_func_begin(NR_EXECUTE_ORIG_ARGS);
22432245
#if ZEND_MODULE_API_NO >= ZEND_8_2_X_API_NO
22442246
if (call_late) {
2245-
nr_php_observer_fcall_begin_late(execute_data, nr_txn_start_time(NRPRG(txn)));
2247+
nr_php_observer_fcall_begin_late(execute_data, nr_txn_start_time(NRPRG(txn)), name_transaction);
22462248
}
22472249
#endif
22482250

@@ -2298,10 +2300,13 @@ void nr_php_observer_fcall_end(zend_execute_data* execute_data,
22982300

22992301
#if ZEND_MODULE_API_NO >= ZEND_8_2_X_API_NO
23002302
void nr_php_observer_fcall_begin(zend_execute_data* execute_data) {
2301-
nr_php_observer_fcall_begin_common(execute_data, false);
2303+
nr_php_observer_fcall_begin_common(execute_data, false, false);
23022304
}
23032305
void nr_php_observer_fcall_begin_instrumented(zend_execute_data* execute_data) {
2304-
nr_php_observer_fcall_begin_common(execute_data, true);
2306+
nr_php_observer_fcall_begin_common(execute_data, true, false);
2307+
}
2308+
void nr_php_observer_fcall_begin_name_transaction(zend_execute_data* execute_data) {
2309+
nr_php_observer_fcall_begin_common(execute_data, true, true);
23052310
}
23062311
void nr_php_observer_fcall_end(zend_execute_data* execute_data,
23072312
zval* func_return_value) {
@@ -2332,6 +2337,11 @@ void nr_php_observer_empty_fcall_end(zend_execute_data* execute_data,
23322337
zval* func_return_value) {
23332338
(void)execute_data;
23342339
(void)func_return_value;
2340+
2341+
/* need a way to register framework info while tt_detail is 0 */
2342+
if (nrunlikely(OP_ARRAY_IS_A_FILE(NR_OP_ARRAY))) {
2343+
nr_php_execute_file(NR_OP_ARRAY, NR_EXECUTE_ORIG_ARGS);
2344+
}
23352345
}
23362346

23372347
#endif

agent/php_observer.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,9 @@ static zend_observer_fcall_handlers nr_php_fcall_register_handlers(
118118
(zend_observer_fcall_begin_handler) wraprec->special_instrumentation_before :
119119
wraprec->is_transient ?
120120
nr_php_observer_fcall_begin :
121-
nr_php_observer_fcall_begin_instrumented;
121+
wraprec->is_names_wt_simple ?
122+
nr_php_observer_fcall_begin_name_transaction :
123+
nr_php_observer_fcall_begin_instrumented;
122124
handlers.end = wraprec->special_instrumentation ?
123125
(zend_observer_fcall_end_handler) wraprec->special_instrumentation :
124126
wraprec->is_exception_handler ?

agent/php_observer.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,11 @@ void nr_php_observer_overwrite_handlers(zend_function* func, nruserfn_t* wraprec
8383

8484
void nr_php_observer_empty_fcall_begin(zend_execute_data* execute_data);
8585
void nr_php_observer_fcall_begin_instrumented(zend_execute_data* execute_data);
86+
void nr_php_observer_fcall_begin_name_transaction(zend_execute_data* execute_data);
8687

8788
void nr_php_observer_empty_fcall_end(zend_execute_data* execute_data,
8889
zval* func_return_value);
89-
void nr_php_observer_fcall_begin_late(zend_execute_data* execute_data, nrtime_t txn_start_time);
90+
void nr_php_observer_fcall_begin_late(zend_execute_data* execute_data, nrtime_t txn_start_time, bool name_transaction);
9091
void nr_php_observer_fcall_end_keep_segment(zend_execute_data* execute_data,
9192
zval* func_return_value);
9293
void nr_php_observer_fcall_end_late(zend_execute_data* execute_data, bool create_metric, nrtime_t txn_start_time);

agent/php_wrapper.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ extern zval** nr_php_get_return_value_ptr(TSRMLS_D);
323323
NR_PHP_WRAPPER_CALL \
324324
} \
325325
if (in_begin) { \
326-
nr_php_observer_fcall_begin_late(execute_data, txn_start_time);\
326+
nr_php_observer_fcall_begin_late(execute_data, txn_start_time, false);\
327327
} else { \
328328
nr_php_observer_fcall_end_late(execute_data, false, txn_start_time); \
329329
} \

0 commit comments

Comments
 (0)