New Relic Application Performance Monitoring (APM) is available in Multi-Experience Operations (MEO) environments. By default, New Relic reports all site traffic under a single application name for each environment. If you run multiple sites in an MEO multisite configuration, you can split New Relic reporting so that each site reports under its own application name in your New Relic account. This is useful when you want to identify performance issues on a specific site rather than diagnosing across a combined aggregate view.
settings.php file for the application, for example, docroot/sites/default/settings.php.newrelic.appname value.settings.php file.Add the following code to settings.php, replacing <CURRENT_APP_NAME> with your environment's actual New Relic application name:
if (extension_loaded('newrelic')) {
$env = isset($_ENV['AH_SITE_ENVIRONMENT']) ? $_ENV['AH_SITE_ENVIRONMENT'] : 'local';
$site_name = isset($_ENV['AH_DRUPAL_SITE_NAME']) ? $_ENV['AH_DRUPAL_SITE_NAME'] : '';
if (!empty($site_name)) {
newrelic_set_appname("<CURRENT_APP_NAME>.$env.$site_name;<CURRENT_APP_NAME>.$env", '', 'true');
}
}The variables in this code block function as follows:
$_ENV['AH_SITE_ENVIRONMENT']: Contains the environment name, such as prod, stage, or dev, set by Acquialocal when not running on Acquia infrastructure$_ENV['AH_DRUPAL_SITE_NAME']: Contains the Drupal site name for the current site in the MEO multisite configurationThe newrelic_set_appname() function accepts three parameters:
myapp.prod.site1, is the per-site identifier and serves as the unique key. The second name, for example, myapp.prod, is the catch-all that continues to provide an aggregate view of all sites on the environment. Replace <CURRENT_APP_NAME> with the exact value of newrelic.appname found in New Relic. The name displayed in the New Relic UI can differ from the internal app name value; use the internal value'') to use the global key already configured for your environment.'true', New Relic retains any transaction data collected before the app name was changed. Retaining transaction data introduces minor performance overheadsettings.php and deploy the file to your MEO environment.Because PHP processes the settings.php file during PHP bootstrap before Drupal fully initializes, the New Relic PHP agent bootstraps against the primary catch-all application name