Giter Site home page Giter Site logo

wp-newrelic's Introduction

WP New Relic

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 6.7.0.174. 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)

Development

The WP New Relic plugin is developed and maintained by 10up, Inc.

License

The WP New Relic plugin is released under the GNU Public License v2 or later.

Issues

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!

wp-newrelic's People

Contributors

ritesh-patel avatar brandwaffle avatar nicholasio avatar allan23 avatar herewithme avatar goldenapples avatar eugene-manuilov avatar jeckman avatar rahe avatar tott avatar ninnypants avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.