Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wordpress: skip hooks from file #37

Merged
merged 2 commits into from
Nov 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions agent/fw_wordpress.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand Down
3 changes: 3 additions & 0 deletions agent/php_newrelic.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
8 changes: 8 additions & 0 deletions agent/php_nrini.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
9 changes: 9 additions & 0 deletions agent/scripts/newrelic.ini.private.template
Original file line number Diff line number Diff line change
Expand Up @@ -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=""