diff --git a/ecommerce/core/tests/test_views.py b/ecommerce/core/tests/test_views.py index 756b6ce5cb7..1b9709e1288 100644 --- a/ecommerce/core/tests/test_views.py +++ b/ecommerce/core/tests/test_views.py @@ -26,11 +26,11 @@ def test_all_services_available(self): """Test that the endpoint reports when all services are healthy.""" self._assert_health(status.HTTP_200_OK, Status.OK, Status.OK) - @mock.patch('newrelic.agent') - def test_health_check_is_ignored_by_new_relic(self, mock_newrelic_agent): - """Test that the health endpoint is ignored by NewRelic""" + @mock.patch('edx_django_utils.monitoring.ignore_transaction') + def test_health_check_is_ignored(self, mock_ignore_transaction): + """Test that the health endpoint is ignored in performance monitoring""" self._assert_health(status.HTTP_200_OK, Status.OK, Status.OK) - self.assertTrue(mock_newrelic_agent.ignore_transaction.called) + self.assertTrue(mock_ignore_transaction.called) @mock.patch('django.contrib.sites.middleware.get_current_site', mock.Mock(return_value=None)) @mock.patch('django.db.backends.base.base.BaseDatabaseWrapper.cursor', mock.Mock(side_effect=DatabaseError)) diff --git a/ecommerce/core/views.py b/ecommerce/core/views.py index 62b95ad815b..e6eb1c5b9c2 100644 --- a/ecommerce/core/views.py +++ b/ecommerce/core/views.py @@ -13,14 +13,10 @@ from django.shortcuts import redirect from django.utils.decorators import method_decorator from django.views.generic import View +from edx_django_utils.monitoring import ignore_transaction from ecommerce.core.constants import Status -try: - import newrelic.agent -except ImportError: # pragma: no cover - newrelic = None # pylint: disable=invalid-name - logger = logging.getLogger(__name__) User = get_user_model() @@ -44,8 +40,8 @@ def health(_): >>> response.content '{"overall_status": "OK", "detailed_status": {"database_status": "OK"}}' """ - if newrelic: # pragma: no cover - newrelic.agent.ignore_transaction() + # Ignores health check in performance monitoring so as to not artifically inflate our response time metrics + ignore_transaction() overall_status = database_status = Status.UNAVAILABLE