diff --git a/agent/fw_wordpress.c b/agent/fw_wordpress.c index 5e0bedf46..4f9544636 100644 --- a/agent/fw_wordpress.c +++ b/agent/fw_wordpress.c @@ -381,6 +381,7 @@ NR_PHP_WRAPPER_END static void nr_wordpress_call_user_func_array(zend_function* func, const zend_function* caller NRUNUSED TSRMLS_DC) { + const char* filename; /* * We only want to hook the function being called if this is a WordPress * function, we're instrumenting hooks, and WordPress is currently executing @@ -391,6 +392,17 @@ static void nr_wordpress_call_user_func_array(zend_function* func, return; } + if (NRINI(wordpress_hooks_skip_filename) + && 0 != nr_strlen(NRINI(wordpress_hooks_skip_filename))) { + filename = nr_php_op_array_file_name(&func->op_array); + + if (nr_strstr(filename, NRINI(wordpress_hooks_skip_filename))) { + nrl_verbosedebug(NRL_FRAMEWORK, "skipping hooks for function from %s", + filename); + return; + } + } + /* * We'll wrap this as a callable to handle anonymous functions being * registered. diff --git a/agent/php_newrelic.h b/agent/php_newrelic.h index 2025ea23d..87dca3be9 100644 --- a/agent/php_newrelic.h +++ b/agent/php_newrelic.h @@ -249,6 +249,9 @@ nrinistr_t browser_monitoring_loader; /* newrelic.browser_monitoring.loader */ nrinibool_t drupal_modules; /* newrelic.framework.drupal.modules */ nrinibool_t wordpress_hooks; /* newrelic.framework.wordpress.hooks */ +nrinistr_t + wordpress_hooks_skip_filename; /* newrelic.framework.wordpress.hooks_skip_filename + */ nrinibool_t analytics_events_enabled; /* DEPRECATED newrelic.analytics_events.enabled */ diff --git a/agent/php_nrini.c b/agent/php_nrini.c index 7afddcfb7..6e054f9d4 100644 --- a/agent/php_nrini.c +++ b/agent/php_nrini.c @@ -1964,6 +1964,14 @@ STD_PHP_INI_ENTRY_EX("newrelic.framework.wordpress.hooks", zend_newrelic_globals, newrelic_globals, nr_on_off_dh) +STD_PHP_INI_ENTRY_EX("newrelic.framework.wordpress.hooks_skip_filename", + "", + NR_PHP_REQUEST, + nr_string_mh, + wordpress_hooks_skip_filename, + zend_newrelic_globals, + newrelic_globals, + 0) STD_PHP_INI_ENTRY_EX("newrelic.framework", "", NR_PHP_REQUEST, diff --git a/agent/scripts/newrelic.ini.private.template b/agent/scripts/newrelic.ini.private.template index a55c10723..b638a16f0 100644 --- a/agent/scripts/newrelic.ini.private.template +++ b/agent/scripts/newrelic.ini.private.template @@ -192,3 +192,12 @@ ; sent to the daemon when Infinite Tracing is enabled. ; ;newrelic.infinite_tracing.span_events.agent_queue.timeout=1s + +; Setting: newrelic.framework.wordpress.hooks_skip_filename +; Type : string +; Scope : system +; Default: "" +; Info : PHP files that contain this string will not have their Wordpress +; hooks instrumented. +; +;newrelic.framework.wordpress.hooks_skip_filename=""