Skip to content

Commit

Permalink
add metric for ini instrumented
Browse files Browse the repository at this point in the history
  • Loading branch information
ZNeumann committed May 23, 2024
1 parent 2c09632 commit 166b67a
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 13 deletions.
30 changes: 20 additions & 10 deletions agent/php_execute.c
Original file line number Diff line number Diff line change
Expand Up @@ -2007,7 +2007,7 @@ static void nr_php_instrument_func_begin(NR_EXECUTE_PROTO) {
}

#if ZEND_MODULE_API_NO >= ZEND_8_2_X_API_NO
void nr_php_observer_fcall_begin_late(zend_execute_data* execute_data, nrtime_t txn_start_time) {
void nr_php_observer_fcall_begin_late(zend_execute_data* execute_data, nrtime_t txn_start_time, bool name_transaction) {
/*
* During nr_zend_call_oapi_special_before, the transaction may have been
* ended and/or a new transaction may have started. To detect this, we
Expand All @@ -2030,12 +2030,14 @@ void nr_php_observer_fcall_begin_late(zend_execute_data* execute_data, nrtime_t
/*
* Check for, and handle, frameworks.
*/
//if (wraprec->is_names_wt_simple) {
if (name_transaction) {

// nr_txn_name_from_function(NRPRG(txn),
// nr_php_op_array_function_name(NR_OP_ARRAY),
// nr_php_class_entry_name(NR_OP_ARRAY->scope));
//}
nr_txn_name_from_function(NRPRG(txn),
nr_php_op_array_function_name(NR_OP_ARRAY),
NR_OP_ARRAY->scope ?
nr_php_class_entry_name(NR_OP_ARRAY->scope) :
NULL);
}
}
#endif

Expand Down Expand Up @@ -2214,7 +2216,7 @@ static void nr_php_instrument_func_end(NR_EXECUTE_PROTO, bool create_metric, boo
}

#if ZEND_MODULE_API_NO >= ZEND_8_2_X_API_NO
static void nr_php_observer_fcall_begin_common(zend_execute_data* execute_data, bool call_late) {
static void nr_php_observer_fcall_begin_common(zend_execute_data* execute_data, bool call_late, bool name_transaction) {
#else
void nr_php_observer_fcall_begin(zend_execute_data* execute_data) {
#endif
Expand Down Expand Up @@ -2258,7 +2260,7 @@ void nr_php_observer_fcall_begin(zend_execute_data* execute_data) {
nr_php_instrument_func_begin(NR_EXECUTE_ORIG_ARGS);
#if ZEND_MODULE_API_NO >= ZEND_8_2_X_API_NO
if (call_late) {
nr_php_observer_fcall_begin_late(execute_data, nr_txn_start_time(NRPRG(txn)));
nr_php_observer_fcall_begin_late(execute_data, nr_txn_start_time(NRPRG(txn)), name_transaction);
}
#endif

Expand Down Expand Up @@ -2314,10 +2316,13 @@ void nr_php_observer_fcall_end(zend_execute_data* execute_data,

#if ZEND_MODULE_API_NO >= ZEND_8_2_X_API_NO
void nr_php_observer_fcall_begin(zend_execute_data* execute_data) {
nr_php_observer_fcall_begin_common(execute_data, false);
nr_php_observer_fcall_begin_common(execute_data, false, false);
}
void nr_php_observer_fcall_begin_instrumented(zend_execute_data* execute_data) {
nr_php_observer_fcall_begin_common(execute_data, true);
nr_php_observer_fcall_begin_common(execute_data, true, false);
}
void nr_php_observer_fcall_begin_name_transaction(zend_execute_data* execute_data) {
nr_php_observer_fcall_begin_common(execute_data, true, true);
}
void nr_php_observer_fcall_end(zend_execute_data* execute_data,
zval* func_return_value) {
Expand Down Expand Up @@ -2348,6 +2353,11 @@ void nr_php_observer_empty_fcall_end(zend_execute_data* execute_data,
zval* func_return_value) {
(void)execute_data;
(void)func_return_value;

/* need a way to register framework info while tt_detail is 0 */
if (nrunlikely(OP_ARRAY_IS_A_FILE(NR_OP_ARRAY))) {
nr_php_execute_file(NR_OP_ARRAY, NR_EXECUTE_ORIG_ARGS);
}
}

#endif
Expand Down
4 changes: 3 additions & 1 deletion agent/php_observer.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,9 @@ static zend_observer_fcall_handlers nr_php_fcall_register_handlers(
(zend_observer_fcall_begin_handler) wraprec->special_instrumentation_before :
wraprec->is_transient ?
nr_php_observer_fcall_begin :
nr_php_observer_fcall_begin_instrumented;
wraprec->is_names_wt_simple ?
nr_php_observer_fcall_begin_name_transaction :
nr_php_observer_fcall_begin_instrumented;
handlers.end = wraprec->special_instrumentation ?
(zend_observer_fcall_end_handler) wraprec->special_instrumentation :
wraprec->is_exception_handler ?
Expand Down
3 changes: 2 additions & 1 deletion agent/php_observer.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,11 @@ void nr_php_observer_overwrite_handlers(zend_function* func, nruserfn_t* wraprec

void nr_php_observer_empty_fcall_begin(zend_execute_data* execute_data);
void nr_php_observer_fcall_begin_instrumented(zend_execute_data* execute_data);
void nr_php_observer_fcall_begin_name_transaction(zend_execute_data* execute_data);

void nr_php_observer_empty_fcall_end(zend_execute_data* execute_data,
zval* func_return_value);
void nr_php_observer_fcall_begin_late(zend_execute_data* execute_data, nrtime_t txn_start_time);
void nr_php_observer_fcall_begin_late(zend_execute_data* execute_data, nrtime_t txn_start_time, bool name_transaction);
void nr_php_observer_fcall_end_keep_segment(zend_execute_data* execute_data,
zval* func_return_value);
void nr_php_observer_fcall_end_late(zend_execute_data* execute_data, bool create_metric, nrtime_t txn_start_time);
Expand Down
2 changes: 1 addition & 1 deletion agent/php_wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ extern zval** nr_php_get_return_value_ptr(TSRMLS_D);
NR_PHP_WRAPPER_CALL \
} \
if (in_begin) { \
nr_php_observer_fcall_begin_late(execute_data, txn_start_time);\
nr_php_observer_fcall_begin_late(execute_data, txn_start_time, false);\
} else { \
nr_php_observer_fcall_end_late(execute_data, false, txn_start_time); \
} \
Expand Down

0 comments on commit 166b67a

Please sign in to comment.