New Relic for WordPress
After New Relic is activated for a WordPress environment, the New Relic agent is active on the environment’s web containers and batch containers (which run WP-CLI commands and WordPress Cron events). The New Relic agent is not installed on any other parts of VIP’s infrastructure (i.e., the VIP CDN or database containers).
New Relic’s documentation provides additional instructions for controlling which WordPress-specific metrics are sent to New Relic.
Force New Relic to trace a request
Only requests that reach origin are traced by New Relic. Requests served from the edge cache cannot be traced. To force New Relic to trace a request, append ?vip-force-trace=1 to the request URL or pass the request with the response header x-vip-force-trace: 1.
Manually log errors
For debugging purposes, custom errors can logged in New Relic by either manually adding them to the Runtime Logs via PHP or logged only to New Relic by using the function newrelic_notice_error().
Errors can be triggered with code similar to this example:
if ( extension_loaded( 'newrelic' ) ) {
newrelic_notice_error( 'My custom error message' );
}For more information, refer to New Relic’s function documentation.
Note
If there are multiple calls to newrelic_notice_error() in a single transaction, the PHP agent will retain the exception from the last call only.
Alternatively, the newrelic_record_custom_event() function can be used to keep track of data and log events without considering it to be an error.
For more information, refer to New Relic’s function documentation for newrelic_record_custom_event().
New Relic PHP API and SDK
New Relic maintains a suite of PHP functions that can be used by WordPress applications to add data to transactions, name transactions, etc. Their documentation provides a Guide to using the PHP agent API. VIP uses this API to enhance the data provided by all VIP WordPress applications.
Custom PHP INI configuration is not offered for individual WordPress applications (sites) on VIP, but some of the configurations can be set in PHP at runtime using ini_set().
Separate apps out on a per-site basis for multisite
By default, New Relic monitoring data for all network sites on a WordPress multisite environment will be displayed together. To separate monitoring data on a site-per-app basis, add New Relic’s newrelic_set_appname() function to vip-config.php.
For example:
if ( extension_loaded( 'newrelic' ) && defined( 'VIP_GO_APP_ENVIRONMENT' ) && 'production' === VIP_GO_APP_ENVIRONMENT ) {
newrelic_set_appname( $_SERVER['HTTP_HOST'] );
}Network sites that share the same root domain will require additional logic for newrelic_set_appname() to distinguish between them (e.g., if site ID 2 is https://example.com/foo and site ID 3 is https://example.com/bar).
To do this, a version of the following code example should be added to a file in client-mu-plugins (not vip-config.php):
add_action( 'init', 'my_new_relic_appname', -1 );
/**
* Set application name for New Relic.
*
* This is because we want to keep the main site appname the same as before so all data/reports are in the same place.
*
* Ensure PHP agent is available and only when not the main site.
*/
function my_new_relic_appname() {
if ( extension_loaded( 'newrelic' ) &&
defined( 'VIP_GO_APP_ENVIRONMENT' ) &&
'production' === VIP_GO_APP_ENVIRONMENT &&
! is_main_site()
) {
$parsed_site_url = wp_parse_url( site_url() );
$path = $parsed_site_url['path'] ?? '';
newrelic_set_appname( $_SERVER['HTTP_HOST'] . $path );
}
}Last updated: December 02, 2025