From f42acc6fb4e2773b9051d24a76690e177386dcd6 Mon Sep 17 00:00:00 2001 From: Ryan Ahearn Date: Tue, 2 May 2023 16:05:09 -0400 Subject: [PATCH] Enable turning off browser monitoring when new relic is disabled --- app/config.py | 3 +++ app/templates/main_template.html | 5 ++++- newrelic.ini | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/config.py b/app/config.py index 3f4cd1964..34da3b1a8 100644 --- a/app/config.py +++ b/app/config.py @@ -1,6 +1,7 @@ import json from os import getenv +import newrelic.agent import pytz from app.cloudfoundry_config import cloud_config @@ -33,6 +34,8 @@ class Config(object): NR_AGENT_ID = getenv('NR_AGENT_ID') NR_APP_ID = getenv('NR_APP_ID') NR_BROWSER_KEY = getenv('NR_BROWSER_KEY') + settings = newrelic.agent.global_settings() + NR_MONITOR_ON = settings and settings.monitor_mode TEMPLATE_PREVIEW_API_HOST = getenv('TEMPLATE_PREVIEW_API_HOST', 'http://localhost:9999') TEMPLATE_PREVIEW_API_KEY = getenv('TEMPLATE_PREVIEW_API_KEY', 'my-secret-key') diff --git a/app/templates/main_template.html b/app/templates/main_template.html index 6eb124ca4..c6f6fbbc6 100644 --- a/app/templates/main_template.html +++ b/app/templates/main_template.html @@ -10,7 +10,10 @@ {% block pageTitle %}U.S. Notify{% endblock %} {# Hardcoded value of $govuk-black #} - {% include "partials/newrelic.html" -%} + {% if config['NR_MONITOR_ON'] %} + {% include "partials/newrelic.html" -%} + {% endif %} + {# Ensure that older IE versions always render with the correct rendering engine #} diff --git a/newrelic.ini b/newrelic.ini index f3436dd73..8d8df6f36 100644 --- a/newrelic.ini +++ b/newrelic.ini @@ -45,7 +45,7 @@ distributed_tracing.enabled = true # application and reports this data to the New Relic UI at # newrelic.com. This global switch is normally overridden for # each environment below. -monitor_mode = true +monitor_mode = false # Sets the name of a file to log agent messages to. Useful for # debugging any issues with the agent. This is not set by