Acquia Support uses New Relic as a tool to help diagnose website performance problems. The New Relic service injects a small JavaScript agent into pages, allowing New Relic to gather data about the end user’s experience. This JavaScript injection may conflict with other JavaScript used on a website or cause validation errors, like the following validation error from Google’s AMP service:
The tag 'script' is disallowed except in specific forms.
New Relic’s documentation
provides the newrelic_disable_autorum()
method to disable the injection of
the New Relic Browser JavaScript agent for the current transaction.
To apply this code to a Drupal website, add the code for your version of Drupal
to the bottom of your website’s settings.php
file, adjusting
[path_to_ignore]
to the actual pages or paths you don’t want the New Relic
agent to be injected into.
Current Drupal version
if (isset($_SERVER['REQUEST_URI']) && strpos($_SERVER['REQUEST_URI'], '[path_to_ignore]') !== false ) {
if (extension_loaded('newrelic')) { // Ensure PHP agent is available
newrelic_disable_autorum();
}
}
Drupal 7
if (isset($_GET['q']) && strpos($_GET['q'], '[path_to_ignore]') === 0) {
if (extension_loaded('newrelic')) { // Ensure PHP agent is available
newrelic_disable_autorum();
}