Skip to content

Commit

Permalink
Merge pull request #596 from newrelic/dev
Browse files Browse the repository at this point in the history
Release 10.5
  • Loading branch information
lavarou authored Jan 13, 2023
2 parents 30f9fca + 5f70349 commit f21ec1e
Show file tree
Hide file tree
Showing 29 changed files with 1,378 additions and 385 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ For more information about CLAs, please check out Alex Russell’s excellent pos

## Slack

We host a public Slack with a dedicated channel for contributors and maintainers of open source projects hosted by New Relic. If you are contributing to this project, you're welcome to request access to the #oss-contributors channel in the newrelicusers.slack.com workspace. To request access, see https://newrelicusers-signup.herokuapp.com/.
We host a public Slack with a dedicated channel for contributors and maintainers of open source projects hosted by New Relic. If you are contributing to this project, you're welcome to request access to the #oss-contributors channel in the newrelicusers.slack.com workspace. To request access, please use this [link](https://join.slack.com/t/newrelicusers/shared_invite/zt-1ayj69rzm-~go~Eo1whIQGYnu3qi15ng).
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
10.4.0
10.5.0
1 change: 1 addition & 0 deletions agent/Makefile.frag
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ TEST_BINARIES = \
tests/test_txn \
tests/test_txn_private \
tests/test_user_instrument \
tests/test_user_instrument_hashmap \
tests/test_zval

.PHONY: unit-tests
Expand Down
2 changes: 1 addition & 1 deletion agent/config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ if test "$PHP_NEWRELIC" = "yes"; then
php_pdo_mysql.c php_pdo_pgsql.c php_pgsql.c php_psr7.c php_redis.c \
php_rinit.c php_rshutdown.c php_samplers.c php_stack.c \
php_stacked_segment.c php_txn.c php_user_instrument.c \
php_vm.c php_wrapper.c"
php_user_instrument_hashmap.c php_vm.c php_wrapper.c"
FRAMEWORKS="fw_cakephp.c fw_codeigniter.c fw_drupal8.c \
fw_drupal.c fw_drupal_common.c fw_joomla.c fw_kohana.c \
fw_laminas3.c fw_laravel.c fw_laravel_queue.c fw_lumen.c \
Expand Down
2 changes: 1 addition & 1 deletion agent/fw_drupal8.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ static void nr_drupal8_add_method_callback(const zend_class_entry* ce,
#if ZEND_MODULE_API_NO < ZEND_7_4_X_API_NO
if (NULL == nr_php_op_array_get_wraprec(&function->op_array TSRMLS_CC)) {
#else
if (NULL == nr_php_get_wraprec_by_func(function)) {
if (NULL == nr_php_get_wraprec(function)) {
#endif
char* class_method = nr_formatf(
"%.*s::%.*s", NRSAFELEN(nr_php_class_entry_name_length(ce)),
Expand Down
18 changes: 11 additions & 7 deletions agent/php_execute.c
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ static void nr_php_show_exec(NR_EXECUTE_PROTO TSRMLS_DC) {
#if ZEND_MODULE_API_NO < ZEND_7_4_X_API_NO
nr_php_op_array_get_wraprec(NR_OP_ARRAY TSRMLS_CC) ? " *" : "",
#else
nr_php_get_wraprec_by_func(execute_data->func) ? " *" : "",
nr_php_get_wraprec(execute_data->func) ? " *" : "",
#endif
NRP_FILENAME(filename), NR_OP_ARRAY->line_start);
} else if (NR_OP_ARRAY->function_name) {
Expand All @@ -668,7 +668,7 @@ static void nr_php_show_exec(NR_EXECUTE_PROTO TSRMLS_DC) {
#if ZEND_MODULE_API_NO < ZEND_7_4_X_API_NO
nr_php_op_array_get_wraprec(NR_OP_ARRAY TSRMLS_CC) ? " *" : "",
#else
nr_php_get_wraprec_by_func(execute_data->func) ? " *" : "",
nr_php_get_wraprec(execute_data->func) ? " *" : "",
#endif
NRP_FILENAME(filename), NR_OP_ARRAY->line_start);
} else if (NR_OP_ARRAY->filename) {
Expand Down Expand Up @@ -1334,7 +1334,7 @@ static void nr_php_execute_enabled(NR_EXECUTE_PROTO TSRMLS_DC) {
#if ZEND_MODULE_API_NO < ZEND_7_4_X_API_NO
wraprec = nr_php_op_array_get_wraprec(NR_OP_ARRAY TSRMLS_CC);
#else
wraprec = nr_php_get_wraprec_by_func(execute_data->func);
wraprec = nr_php_get_wraprec(execute_data->func);
#endif

if (NULL != wraprec) {
Expand Down Expand Up @@ -1686,11 +1686,15 @@ void nr_php_user_instrumentation_from_opcache(TSRMLS_D) {
"status, even though opcache.preload is set");
return;
}

if (IS_ARRAY != Z_TYPE_P(status)) {
nrl_warning(NRL_INSTRUMENT,
"User instrumentation from opcache: opcache status "
"information is not an array");
/*
* `opcache_get_status` returns either an array or false. If it's not an
* array, it must have returned false indicating we are unable to get the
* status yet.
*/
nrl_debug(NRL_INSTRUMENT,
"User instrumentation from opcache: opcache status "
"information is not an array");
goto end;
}

Expand Down
2 changes: 2 additions & 0 deletions agent/php_newrelic.h
Original file line number Diff line number Diff line change
Expand Up @@ -485,13 +485,15 @@ nriniuint_t log_forwarding_log_level; /* newrelic.application_logging.forwarding
nrinibool_t
code_level_metrics_enabled; /* newrelic.code_level_metrics.enabled */

#if ZEND_MODULE_API_NO < ZEND_7_4_X_API_NO
/*
* pid and user_function_wrappers are used to store user function wrappers.
* Storing this on a request level (as opposed to storing it on transaction
* level) is more robust when using multiple transactions in one request.
*/
uint64_t pid;
nr_vector_t* user_function_wrappers;
#endif

nrapp_t* app; /* The application used in the last attempt to initialize a
transaction */
Expand Down
5 changes: 5 additions & 0 deletions agent/php_rinit.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "php_error.h"
#include "php_globals.h"
#include "php_header.h"
#include "php_user_instrument.h"
#include "nr_datastore_instance.h"
#include "nr_txn.h"
#include "nr_rum.h"
Expand All @@ -35,8 +36,12 @@ PHP_RINIT_FUNCTION(newrelic) {
NRPRG(php_cur_stack_depth) = 0;
NRPRG(deprecated_capture_request_parameters) = NRINI(capture_params);
NRPRG(sapi_headers) = NULL;
#if ZEND_MODULE_API_NO >= ZEND_7_4_X_API_NO
nr_php_init_user_instrumentation();
#else
NRPRG(pid) = getpid();
NRPRG(user_function_wrappers) = nr_vector_create(64, NULL, NULL);
#endif

if ((0 == NR_PHP_PROCESS_GLOBALS(enabled)) || (0 == NRINI(enabled))) {
return SUCCESS;
Expand Down
4 changes: 4 additions & 0 deletions agent/php_rshutdown.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,11 @@ int nr_php_post_deactivate(void) {
nr_free(NRPRG(predis_ctx));
nr_hashmap_destroy(&NRPRG(predis_commands));

#if ZEND_MODULE_API_NO >= ZEND_7_4_X_API_NO
nr_php_reset_user_instrumentation();
#else
nr_vector_destroy(&NRPRG(user_function_wrappers));
#endif

NRPRG(cufa_callback) = NULL;

Expand Down
45 changes: 26 additions & 19 deletions agent/php_txn.c
Original file line number Diff line number Diff line change
Expand Up @@ -625,14 +625,13 @@ static void nr_php_txn_log_error_dt_on_tt_off(void) {
}

static void nr_php_txn_send_metrics_once(nrtxn_t* txn TSRMLS_DC) {
static unsigned int sent = 0;
char* metname = NULL;

if (nrunlikely(NULL == NRPRG(txn))) {
return;
}

if (nrlikely(0 != sent)) {
if (nrlikely(0 != txn->created_logging_onetime_metrics)) {
return;
}

Expand All @@ -648,7 +647,7 @@ static void nr_php_txn_send_metrics_once(nrtxn_t* txn TSRMLS_DC) {
nrm_force_add(NRTXN(unscoped_metrics), metname, 0);
nr_free(metname);

sent = 1;
txn->created_logging_onetime_metrics = true;

#undef FMT_BOOL
}
Expand Down Expand Up @@ -680,7 +679,10 @@ nr_status_t nr_php_txn_begin(const char* appnames,
*/
pfd = nr_get_daemon_fd();

#if ZEND_MODULE_API_NO < ZEND_7_4_X_API_NO
/* For PHP 7.4+ user instrumentation is reset at rshutdown. */
nr_php_reset_user_instrumentation();
#endif

if (pfd < 0) {
nrl_debug(NRL_INIT, "unable to begin transaction: no daemon connection");
Expand All @@ -704,7 +706,8 @@ nr_status_t nr_php_txn_begin(const char* appnames,
}

opts.custom_events_enabled = (int)NRINI(custom_events_enabled);
opts.custom_events_max_samples_stored = NRINI(custom_events_max_samples_stored);
opts.custom_events_max_samples_stored
= NRINI(custom_events_max_samples_stored);
opts.synthetics_enabled = (int)NRINI(synthetics_enabled);
opts.instance_reporting_enabled = (int)NRINI(instance_reporting_enabled);
opts.database_name_reporting_enabled
Expand Down Expand Up @@ -782,12 +785,13 @@ nr_status_t nr_php_txn_begin(const char* appnames,
info.span_queue_size = NRINI(span_queue_size);
info.span_events_max_samples_stored = NRINI(span_events_max_samples_stored);

/* Need to initialize custom and log event max samples to value negotiated between that
* requested in the INI file and the value returned from the daaemon (based in
* part on the collector connect response harvest limits) */
/* Need to initialize custom and log event max samples to value negotiated
* between that requested in the INI file and the value returned from the
* daaemon (based in part on the collector connect response harvest limits) */
info.log_events_max_samples_stored = NRINI(log_events_max_samples_stored);
info.custom_events_max_samples_stored = NRINI(custom_events_max_samples_stored);

info.custom_events_max_samples_stored
= NRINI(custom_events_max_samples_stored);

NRPRG(app) = nr_agent_find_or_add_app(
nr_agent_applist, &info,
/*
Expand Down Expand Up @@ -914,17 +918,20 @@ nr_status_t nr_php_txn_begin(const char* appnames,
nr_php_txn_log_error_dt_on_tt_off();
}

#if ZEND_MODULE_API_NO >= ZEND_8_1_X_API_NO
if (nr_php_ini_setting_is_set_by_user("opcache.enable")
&& NR_PHP_PROCESS_GLOBALS(preload_framework_library_detection)) {
nr_php_user_instrumentation_from_opcache(TSRMLS_C);
}
#else
if (nr_php_ini_setting_is_set_by_user("opcache.preload")
&& NR_PHP_PROCESS_GLOBALS(preload_framework_library_detection)) {
nr_php_user_instrumentation_from_opcache(TSRMLS_C);
/*
* Only try to instrument preloaded opcache scripts when opcache enabled and
* preload is not null. If an INI value does not exist, INI_INT/INI_BOOL
* returns 0 and INI_STR returns NULL.
*/
if (NR_PHP_PROCESS_GLOBALS(preload_framework_library_detection)) {
bool opcache_enabled = is_cli
? INI_BOOL("opcache.enable_cli")
: INI_BOOL("opcache.enable");
if ((opcache_enabled)
&& (nr_php_ini_setting_is_set_by_user("opcache.preload"))) {
nr_php_user_instrumentation_from_opcache(TSRMLS_C);
}
}
#endif

return NR_SUCCESS;
}
Expand Down
Loading

0 comments on commit f21ec1e

Please sign in to comment.