Skip to content

Commit 0e35b01

Browse files
ZNeumannlavarou
authored andcommitted
add metric for ini instrumented
1 parent f5252c3 commit 0e35b01

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
@@ -2014,7 +2014,7 @@ static void nr_php_instrument_func_begin(NR_EXECUTE_PROTO) {
20142014
}
20152015

20162016
#if ZEND_MODULE_API_NO >= ZEND_8_2_X_API_NO
2017-
void nr_php_observer_fcall_begin_late(zend_execute_data* execute_data, nrtime_t txn_start_time) {
2017+
void nr_php_observer_fcall_begin_late(zend_execute_data* execute_data, nrtime_t txn_start_time, bool name_transaction) {
20182018
/*
20192019
* During nr_zend_call_oapi_special_before, the transaction may have been
20202020
* ended and/or a new transaction may have started. To detect this, we
@@ -2037,12 +2037,14 @@ void nr_php_observer_fcall_begin_late(zend_execute_data* execute_data, nrtime_t
20372037
/*
20382038
* Check for, and handle, frameworks.
20392039
*/
2040-
//if (wraprec->is_names_wt_simple) {
2040+
if (name_transaction) {
20412041

2042-
// nr_txn_name_from_function(NRPRG(txn),
2043-
// nr_php_op_array_function_name(NR_OP_ARRAY),
2044-
// nr_php_class_entry_name(NR_OP_ARRAY->scope));
2045-
//}
2042+
nr_txn_name_from_function(NRPRG(txn),
2043+
nr_php_op_array_function_name(NR_OP_ARRAY),
2044+
NR_OP_ARRAY->scope ?
2045+
nr_php_class_entry_name(NR_OP_ARRAY->scope) :
2046+
NULL);
2047+
}
20462048
}
20472049
#endif
20482050

@@ -2221,7 +2223,7 @@ static void nr_php_instrument_func_end(NR_EXECUTE_PROTO, bool create_metric, boo
22212223
}
22222224

22232225
#if ZEND_MODULE_API_NO >= ZEND_8_2_X_API_NO
2224-
static void nr_php_observer_fcall_begin_common(zend_execute_data* execute_data, bool call_late) {
2226+
static void nr_php_observer_fcall_begin_common(zend_execute_data* execute_data, bool call_late, bool name_transaction) {
22252227
#else
22262228
void nr_php_observer_fcall_begin(zend_execute_data* execute_data) {
22272229
#endif
@@ -2265,7 +2267,7 @@ void nr_php_observer_fcall_begin(zend_execute_data* execute_data) {
22652267
nr_php_instrument_func_begin(NR_EXECUTE_ORIG_ARGS);
22662268
#if ZEND_MODULE_API_NO >= ZEND_8_2_X_API_NO
22672269
if (call_late) {
2268-
nr_php_observer_fcall_begin_late(execute_data, nr_txn_start_time(NRPRG(txn)));
2270+
nr_php_observer_fcall_begin_late(execute_data, nr_txn_start_time(NRPRG(txn)), name_transaction);
22692271
}
22702272
#endif
22712273

@@ -2321,10 +2323,13 @@ void nr_php_observer_fcall_end(zend_execute_data* execute_data,
23212323

23222324
#if ZEND_MODULE_API_NO >= ZEND_8_2_X_API_NO
23232325
void nr_php_observer_fcall_begin(zend_execute_data* execute_data) {
2324-
nr_php_observer_fcall_begin_common(execute_data, false);
2326+
nr_php_observer_fcall_begin_common(execute_data, false, false);
23252327
}
23262328
void nr_php_observer_fcall_begin_instrumented(zend_execute_data* execute_data) {
2327-
nr_php_observer_fcall_begin_common(execute_data, true);
2329+
nr_php_observer_fcall_begin_common(execute_data, true, false);
2330+
}
2331+
void nr_php_observer_fcall_begin_name_transaction(zend_execute_data* execute_data) {
2332+
nr_php_observer_fcall_begin_common(execute_data, true, true);
23282333
}
23292334
void nr_php_observer_fcall_end(zend_execute_data* execute_data,
23302335
zval* func_return_value) {
@@ -2355,6 +2360,11 @@ void nr_php_observer_empty_fcall_end(zend_execute_data* execute_data,
23552360
zval* func_return_value) {
23562361
(void)execute_data;
23572362
(void)func_return_value;
2363+
2364+
/* need a way to register framework info while tt_detail is 0 */
2365+
if (nrunlikely(OP_ARRAY_IS_A_FILE(NR_OP_ARRAY))) {
2366+
nr_php_execute_file(NR_OP_ARRAY, NR_EXECUTE_ORIG_ARGS);
2367+
}
23582368
}
23592369

23602370
#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)