-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: improve wordpress hooks ini (#814)
Hide boolean flags controling wordpress hooks instrumentation behind a `newrelic.framework.wordpress.hooks.options` facade. The facade makes invalid combinations of boolean flags impossible to set. Additionally do not surprise users with a change to agent behavior. Set the new toggles to values that maintain behavior. This allows for transition period when users can understand the new feature and be prepared for the change.
- Loading branch information
Showing
14 changed files
with
184 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
tests/integration/frameworks/wordpress/test_wordpress_00_1.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
/* | ||
* Copyright 2020 New Relic Corporation. All rights reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
/*DESCRIPTION | ||
Test that agent falls back to WordPress default instrumentation when the settings in INI are invalid. | ||
The agent should: | ||
- detect WordPress framework | ||
- name the web transaction as an 'Action' named after the template used to generate the page | ||
- detect custom plugins and themes | ||
- generate hooks metrics for all callback functions executions; the execution time of callback | ||
functions from wordpress core, custom plugins and themes is captured. | ||
No errors should be generated. | ||
*/ | ||
|
||
/*INI | ||
newrelic.framework.wordpress.hooks.options= | ||
*/ | ||
|
||
/*ENVIRONMENT | ||
REQUEST_METHOD=GET | ||
*/ | ||
|
||
/*EXPECT_METRICS_EXIST | ||
Supportability/framework/WordPress/detected | ||
WebTransaction/Action/page-template | ||
Supportability/InstrumentedFunction/apply_filters | ||
Supportability/InstrumentedFunction/do_action | ||
Framework/WordPress/Hook/wp_loaded | ||
Framework/WordPress/Hook/template_include | ||
Framework/WordPress/Plugin/mock-plugin1 | ||
Framework/WordPress/Plugin/mock-plugin2 | ||
Framework/WordPress/Plugin/mock-theme1 | ||
Framework/WordPress/Plugin/mock-theme2 | ||
Framework/WordPress/Hook/wp_init | ||
Framework/WordPress/Hook/the_content | ||
*/ | ||
|
||
/*EXPECT_METRICS_DONT_EXIST | ||
*/ | ||
|
||
/*EXPECT_ERROR_EVENTS null */ | ||
|
||
/* WordPress mock app */ | ||
require_once __DIR__.'/mock-wordpress-app.php'; |
47 changes: 47 additions & 0 deletions
47
tests/integration/frameworks/wordpress/test_wordpress_00_2.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
/* | ||
* Copyright 2020 New Relic Corporation. All rights reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
/*DESCRIPTION | ||
Test that agent falls back to WordPress default instrumentation when the settings in INI are invalid. | ||
The agent should: | ||
- detect WordPress framework | ||
- name the web transaction as an 'Action' named after the template used to generate the page | ||
- detect custom plugins and themes | ||
- generate hooks metrics for all callback functions executions; the execution time of callback | ||
functions from wordpress core, custom plugins and themes is captured. | ||
No errors should be generated. | ||
*/ | ||
|
||
/*INI | ||
newrelic.framework.wordpress.hooks.options="foobar" | ||
*/ | ||
|
||
/*ENVIRONMENT | ||
REQUEST_METHOD=GET | ||
*/ | ||
|
||
/*EXPECT_METRICS_EXIST | ||
Supportability/framework/WordPress/detected | ||
WebTransaction/Action/page-template | ||
Supportability/InstrumentedFunction/apply_filters | ||
Supportability/InstrumentedFunction/do_action | ||
Framework/WordPress/Hook/wp_loaded | ||
Framework/WordPress/Hook/template_include | ||
Framework/WordPress/Plugin/mock-plugin1 | ||
Framework/WordPress/Plugin/mock-plugin2 | ||
Framework/WordPress/Plugin/mock-theme1 | ||
Framework/WordPress/Plugin/mock-theme2 | ||
Framework/WordPress/Hook/wp_init | ||
Framework/WordPress/Hook/the_content | ||
*/ | ||
|
||
/*EXPECT_METRICS_DONT_EXIST | ||
*/ | ||
|
||
/*EXPECT_ERROR_EVENTS null */ | ||
|
||
/* WordPress mock app */ | ||
require_once __DIR__.'/mock-wordpress-app.php'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.