Skip to content

Commit 7c985b8

Browse files
authored
feat(agent): update default for wp hooks options (#880)
To reduce agent's overhead, by default the agent will only instrument hook callbacks from plugins/themes and will not instrument hook callbacks from wordpress core.
1 parent 5b964b4 commit 7c985b8

9 files changed

+33
-36
lines changed

agent/php_nrini.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1896,7 +1896,7 @@ static PHP_INI_MH(nr_custom_events_max_samples_stored_mh) {
18961896
return SUCCESS;
18971897
}
18981898

1899-
#define DEFAULT_WORDPRESS_HOOKS_OPTIONS "all_callbacks"
1899+
#define DEFAULT_WORDPRESS_HOOKS_OPTIONS "plugin_callbacks"
19001900
static PHP_INI_MH(nr_wordpress_hooks_options_mh) {
19011901
nrinistr_t* p;
19021902

agent/scripts/newrelic.ini.template

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1169,17 +1169,17 @@ newrelic.daemon.logfile = "/var/log/newrelic/newrelic-daemon.log"
11691169
; Setting: newrelic.framework.wordpress.hooks.options
11701170
; Type : string (all_callbacks, plugin_callbacks, threshold)
11711171
; Scope : per-directory
1172-
; Default: all_callbacks
1172+
; Default: plugin_callbacks
11731173
; Info : Sets the options how WordPress hooks are instrumented.
11741174
;
11751175
; New Relic agent can provide different levels of insights into WordPress hooks.
1176-
; By default, all hook callbacks functions are instrumented ("all_callbacks").
1177-
; To reduce agent's overhead it is possible to limit the instrumentation to only
1178-
; plugin/theme callbacks ("plugin_callbacks"). Third option is to monitor hooks
1179-
; without instrumenting callbacks ("threshold"). This option does not give insights
1180-
; about plugins/themes.
1176+
; By default, only plugin/theme callbacks are instrumented ("plugin_callbacks").
1177+
; At the cost of increased agent's overhead it is possible to extend the
1178+
; instrumentation to all hook callbacks functions ("all_callbacks"). Third option
1179+
; is to monitor hooks without instrumenting callbacks ("threshold"). This option
1180+
; does not give insights about plugins/themes.
11811181
;
1182-
;newrelic.framework.wordpress.hooks.options = "all_callbacks"
1182+
;newrelic.framework.wordpress.hooks.options = "plugin_callbacks"
11831183

11841184
; Setting: newrelic.framework.wordpress.hooks.threshold
11851185
; Type : time specification string ("500ms", "1s750ms" etc)

tests/integration/frameworks/wordpress/test_wordpress_00.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
- detect WordPress framework
1010
- name the web transaction as an 'Action' named after the template used to generate the page
1111
- detect custom plugins and themes
12-
- generate hooks metrics for all callback functions executions; the execution time of callback
13-
functions from wordpress core, custom plugins and themes is captured.
12+
- generate hooks metrics only for plugins and themes callback functions executions;
13+
only the execution time of callback functions from custom plugins and themes is captured.
1414
No errors should be generated.
1515
*/
1616

@@ -40,11 +40,11 @@ functions from wordpress core, custom plugins and themes is captured.
4040
Framework/WordPress/Plugin/mock-plugin2
4141
Framework/WordPress/Plugin/mock-theme1
4242
Framework/WordPress/Plugin/mock-theme2
43-
Framework/WordPress/Hook/wp_init
44-
Framework/WordPress/Hook/the_content
4543
*/
4644

4745
/*EXPECT_METRICS_DONT_EXIST
46+
Framework/WordPress/Hook/wp_init
47+
Framework/WordPress/Hook/the_content
4848
*/
4949

5050
/*EXPECT_ERROR_EVENTS null */

tests/integration/frameworks/wordpress/test_wordpress_00.php7.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
- detect WordPress framework
1010
- name the web transaction as an 'Action' named after the template used to generate the page
1111
- detect custom plugins and themes
12-
- generate hooks metrics for all callback functions executions; the execution time of callback
13-
functions from wordpress core, custom plugins and themes is captured.
12+
- generate hooks metrics only for plugins and themes callback functions executions;
13+
only the execution time of callback functions from custom plugins and themes is captured.
1414
No errors should be generated.
1515
*/
1616

@@ -32,11 +32,11 @@ functions from wordpress core, custom plugins and themes is captured.
3232
Framework/WordPress/Plugin/mock-plugin2
3333
Framework/WordPress/Plugin/mock-theme1
3434
Framework/WordPress/Plugin/mock-theme2
35-
Framework/WordPress/Hook/wp_init
36-
Framework/WordPress/Hook/the_content
3735
*/
3836

3937
/*EXPECT_METRICS_DONT_EXIST
38+
Framework/WordPress/Hook/wp_init
39+
Framework/WordPress/Hook/the_content
4040
*/
4141

4242
/*EXPECT_ERROR_EVENTS null */

tests/integration/frameworks/wordpress/test_wordpress_00_1.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
- detect WordPress framework
1111
- name the web transaction as an 'Action' named after the template used to generate the page
1212
- detect custom plugins and themes
13-
- generate hooks metrics for all callback functions executions; the execution time of callback
14-
functions from wordpress core, custom plugins and themes is captured.
13+
- generate hooks metrics only for plugins and themes callback functions executions;
14+
only the execution time of callback functions from custom plugins and themes is captured.
1515
No errors should be generated.
1616
*/
1717

@@ -34,11 +34,11 @@ functions from wordpress core, custom plugins and themes is captured.
3434
Framework/WordPress/Plugin/mock-plugin2
3535
Framework/WordPress/Plugin/mock-theme1
3636
Framework/WordPress/Plugin/mock-theme2
37-
Framework/WordPress/Hook/wp_init
38-
Framework/WordPress/Hook/the_content
3937
*/
4038

4139
/*EXPECT_METRICS_DONT_EXIST
40+
Framework/WordPress/Hook/wp_init
41+
Framework/WordPress/Hook/the_content
4242
*/
4343

4444
/*EXPECT_ERROR_EVENTS null */

tests/integration/frameworks/wordpress/test_wordpress_00_2.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
- detect WordPress framework
1111
- name the web transaction as an 'Action' named after the template used to generate the page
1212
- detect custom plugins and themes
13-
- generate hooks metrics for all callback functions executions; the execution time of callback
14-
functions from wordpress core, custom plugins and themes is captured.
13+
- generate hooks metrics only for plugins and themes callback functions executions;
14+
only the execution time of callback functions from custom plugins and themes is captured.
1515
No errors should be generated.
1616
*/
1717

@@ -34,11 +34,11 @@ functions from wordpress core, custom plugins and themes is captured.
3434
Framework/WordPress/Plugin/mock-plugin2
3535
Framework/WordPress/Plugin/mock-theme1
3636
Framework/WordPress/Plugin/mock-theme2
37-
Framework/WordPress/Hook/wp_init
38-
Framework/WordPress/Hook/the_content
3937
*/
4038

4139
/*EXPECT_METRICS_DONT_EXIST
40+
Framework/WordPress/Hook/wp_init
41+
Framework/WordPress/Hook/the_content
4242
*/
4343

4444
/*EXPECT_ERROR_EVENTS null */

tests/integration/frameworks/wordpress/test_wordpress_apply_filters.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
The agent should properly instrument Wordpress apply_filters hooks. Since the
99
mocked hooks are detected by the agent as WordPress core (plugin_from_function
1010
returns NULL), and WordPress core callbacks are not instrumented by default,
11-
therefore newrelic.framework.wordpress.core needs to be set to true for the
12-
agent to generate the hooks metrics.
11+
therefore newrelic.framework.wordpress.hooks.options needs to be set to
12+
"all_callbacks" for the agent to generate the hooks metrics.
1313
*/
1414

1515
/*SKIPIF
@@ -18,7 +18,7 @@
1818
/*INI
1919
newrelic.framework = wordpress
2020
newrelic.framework.wordpress.hooks_threshold = 0
21-
newrelic.framework.wordpress.core = true
21+
newrelic.framework.wordpress.hooks.options = all_callbacks
2222
*/
2323

2424
/*EXPECT

tests/integration/frameworks/wordpress/test_wordpress_do_action.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,16 @@
88
The agent should properly instrument Wordpress do_action hooks. Since the
99
mocked hooks are detected by the agent as WordPress core (plugin_from_function
1010
returns NULL), and WordPress core callbacks are not instrumented by default,
11-
therefore newrelic.framework.wordpress.core needs to be set to true for the
12-
agent to generate the hooks metrics.
11+
therefore newrelic.framework.wordpress.hooks.options needs to be set to
12+
"all_callbacks" for the agent to generate the hooks metrics.
1313
*/
1414

1515
/*SKIPIF
1616
*/
1717

1818
/*INI
1919
newrelic.framework = wordpress
20-
newrelic.framework.wordpress.hooks_threshold = 0
21-
newrelic.framework.wordpress.core = true
20+
newrelic.framework.wordpress.hooks.options = all_callbacks
2221
*/
2322

2423
/*EXPECT

tests/integration/frameworks/wordpress/test_wordpress_transaction_name_hooks_on.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,15 @@
1111
metric should be generated and the hook function should be instrumented.
1212
However, since the mocked hooks are detected by the agent as WordPress core
1313
(plugin_from_function returns NULL), and WordPress core callbacks are not
14-
instrumented by default, therefore newrelic.framework.wordpress.core needs
15-
to be set to true for the agent to generate the hooks metrics.
14+
instrumented by default, therefore therefore newrelic.framework.wordpress.hooks.options
15+
needs to be set to "all_callbacks" for the agent to generate the hooks metrics.
1616
*/
1717

1818
/*SKIPIF*/
1919

2020
/*INI
2121
newrelic.framework = wordpress
22-
newrelic.framework.wordpress.hooks = true
23-
newrelic.framework.wordpress.hooks_threshold = 0
24-
newrelic.framework.wordpress.core = true
22+
newrelic.framework.wordpress.hooks.options = all_callbacks
2523
*/
2624

2725
/*ENVIRONMENT

0 commit comments

Comments
 (0)