Skip to content

Commit

Permalink
temp: Switch test to call into DatadogBackend.
Browse files Browse the repository at this point in the history
  • Loading branch information
dianakhuang committed Oct 1, 2024
1 parent 0dc18b1 commit 9c1f532
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions edx_django_utils/monitoring/tests/test_custom_monitoring.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from unittest.mock import Mock, call, patch

import ddt
from django.test import TestCase
from django.test import TestCase, override_settings

from edx_django_utils.cache import RequestCache
from edx_django_utils.monitoring import MonitoringSupportMiddleware, accumulate, get_current_transaction, increment
Expand Down Expand Up @@ -113,11 +113,20 @@ def test_accumulate_with_illegal_value(
# Assert call args to newrelic.agent.add_custom_parameter().
mock_newrelic_agent.add_custom_parameter.assert_has_calls(nr_agent_calls_expected, any_order=True)

@patch('edx_django_utils.monitoring.MonitoringSupportMiddleware._tag_root_span_with_error')
def test_error_tagging(self, mock_tag_error):
@patch('ddtrace.Tracer.current_root_span')
def test_error_tagging(self, mock_get_root_span):
# Ensure that we continue to support tagging exceptions in MonitoringSupportMiddleware.
MonitoringSupportMiddleware(self.mock_response).process_exception('fake request', 'fake exception')
mock_tag_error.assert_called_with('fake exception')
# This is only implemented for DatadogBackend at the moment.
fake_exception = Exception()
mock_root_span = Mock()
mock_get_root_span.return_value = mock_root_span
with override_settings(OPENEDX_TELEMETRY=['edx_django_utils.monitoring.DatadogBackend']):
MonitoringSupportMiddleware(self.mock_response).process_exception(
'fake request', fake_exception
)
mock_root_span.set_exc_info.assert_called_with(
type(fake_exception), fake_exception, fake_exception.__traceback__
)

@patch('newrelic.agent')
def test_get_current_transaction(self, mock_newrelic_agent):
Expand Down

0 comments on commit 9c1f532

Please sign in to comment.