Skip to content

Latest commit

 

History

History
138 lines (86 loc) · 9.11 KB

README.md

File metadata and controls

138 lines (86 loc) · 9.11 KB

WP New Relic

WP New Relic

Support Level Required PHP Version Required WP Version Release Version WordPress tested up to version GPL-2.0-or-later License Dependency Review E2E Tests

New Relic APM reports for WordPress.

Overview

WP New Relic (WPNR) is designed to be used with the New Relic APM, and uses the New Relic PHP Agent API to augment existing metrics with valuable WordPress details such as templates, users, request type, and Transaction names. This plugin is tested with New Relic's PHP Agent version 10.19.0.9. Data collected by this plugin can be queried in New Relic's Insights product, using New Relic Query Language (NRQL).

New Relic is a trademark of New Relic, Inc.

Administrative settings

After activating the plugin, You will see a new option named New Relic under the Tools menu in your WordPress Dashboard. If you are running WordPress in Network Mode, the settings page will be found in your Network Dashboard.

wp-nr-settings

Capture URL Parameters

If the Capture URLs setting is enabled, the plugin will capture URL parameters for displaying in Transaction traces. As an example, turning on this feature will store a URL like http://example.com/?p=1234, while leaving it off will result in the URL being stored as http://example.com/. This feature can be useful for debugging or providing granular data if required. In certain cases, however, it can cause confusion by creating a "false positive" appearance of multiple URLs (e.g. UTM codes or tracking info from social media).

Basic Config

By default the plugin will setup 3 New Relic configuration parameters:

appname and capture_params config can be overridden using the wp_nr_config filter. The wp_nr_setup_config action hook can also be used to setup any extra config.

New Relic Custom Attributes

Certain useful custom attributes (you can think of these as 'post meta for New Relic') will be set for each event and can provide additional information related to your WordPress installation. You can query events and filter them using these attributes in New Relic Insights. See the NRQL reference for more details on how to query events.

User

The user attribute is set using newrelic_set_user_attributes. If the user is logged in, the user ID will be set as the user attribute and if not the user attribute will be set to not-logged-in. Ex: In New Relic Insights you can query Transactions for non-logged in users as

SELECT * FROM Transaction WHERE appName = '{appName}' AND user = 'not-logged-in'

Post ID

For single posts, the post ID will be set via the post_id custom attribute.

Ex: Get all Transactions for a post with ID 190.

SELECT * FROM Transaction WHERE appName = '{appName}' AND post_id = '190'

You can also perform more complex queries, such as counting the number of views for a post. This can be helpful for determining top content on your site.

SELECT count(*) FROM Transaction WHERE appName = '{appName}' AND post_id = '190'

Template

For each request, the Template being used is set as the template custom attribute.

Ex: You can query all Transactions for a particular template.

SELECT * FROM Transaction WHERE appName = '{appName}' AND template = '{Absolute Template Path}'

Theme

The current theme is set as the theme custom attribute.

Ex: Query all Transactions running the "Twenty Fifteen" theme.

SELECT * FROM Transaction WHERE appName = '{appName}' AND theme = 'Twenty Fifteen'

Request type

There can be 3 type of requests: web, ajax and cli. The current request type is set as the request_type custom attribute. The request type can be overridden using the wp_nr_request_type filter.

Ex: Get all Transactions for the "ajax" request type

SELECT * FROM Transaction WHERE appName = '{appName}' AND request_type = 'ajax'

Transaction Name

The Transaction name is set based on the main WP_Query parameters using newrelic_name_transaction. Possible values are Default Home Page, Front Page, Blog Page, Network Dashboard, Dashboard, Single - {post_type}, Page - {pagename}, Date Archive, Search Page, Feed, Archive - {post_type}, Category - {cat_name}, Tag - {tag_name}, Tax - {taxonomy} - {term}

Custom Error Logging

Using the wp_nr_log_errors function, any plugin/theme can log errors/notices to New Relic for the current Transaction. Note: This function can be called more than once, but only the last call will log the error to New Relic. This is a known limitation of the PHP Agent API. As a reminder, since the PHP Agent runs only when PHP does, any cached requests will not appear in your error logs.

wp_nr_log_errors( 'Error message', Exception $exception );

Runtime of async tasks

This plugin also tracks the runtime of gearman async tasks. A Gearman async task run for a particular hook and its runtime can be tracked using the “wp_async_task-{hook}” custom attribute and queried in New Relic Insights.

Screenshots

wp-nr-transactions (Transactions in New Relic APM)

wp-nr-single-post-query (New Relic Insights query for a single post)

wp-nr-total-post-view-count (Total post view counts for a single post using post_id custom parameter)

wp-nr-databaseduration-query (Get Template used and Transactions whose database duration is more than 0.1)

Known Issues/Caveats

PHP version

PHP version 7.3.3 is known to cause issues with this plugin, updating to 7.3.11 or greater appears to resolve these issues. For more details, see issue#39.

Have an issue to report?

If you identify any errors or have an idea for improving the plugin, please open an issue. We're excited to see what the community thinks of this project, and we would love your input!

Support Level

Stable: 10up is not planning to develop any new features for this, but will still respond to bug reports and security concerns. We welcome PRs, but any that include new features should be small and easy to integrate and should not include breaking changes. We otherwise intend to keep this tested up to the most recent version of WordPress.

Like what you see?