Skip to content
This repository has been archived by the owner on Nov 4, 2024. It is now read-only.

Commit

Permalink
fix: Replace New Relic ignore_transaction (#4174)
Browse files Browse the repository at this point in the history
REV-4059
  • Loading branch information
julianajlk authored Jul 15, 2024
1 parent 039fe3f commit 147a01a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
8 changes: 4 additions & 4 deletions ecommerce/core/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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('ecommerce.core.views.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))
Expand Down
10 changes: 3 additions & 7 deletions ecommerce/core/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand All @@ -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

Expand Down

0 comments on commit 147a01a

Please sign in to comment.