Skip to content

Commit

Permalink
Merge pull request #274 from uktrade/LTD-5327-fix-sentry-sdk-lookup-e…
Browse files Browse the repository at this point in the history
…rror

[LTD-5327] Update sentry scope pushing call after major version bump
  • Loading branch information
kevincarrogan authored Aug 28, 2024
2 parents cde2e62 + 4b60daa commit 77626bd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion mail/libraries/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ def sort_dtos_by_date(input_dtos):

def log_to_sentry(message, extra=None, level="info"):
extra = extra or {}
with sentry_sdk.push_scope() as scope:
with sentry_sdk.new_scope() as scope:
for key, value in extra.items():
scope.set_extra(key, value)
sentry_sdk.capture_message(message, level=level)
Expand Down
15 changes: 15 additions & 0 deletions mail/tests/libraries/test_helpers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import unittest
from unittest import mock

from mail.libraries.helpers import log_to_sentry


class TestLogToSentry(unittest.TestCase):

@mock.patch("sentry_sdk.scope.Scope.capture_event")
def test_log_to_sentry(self, mock_capture_event):
log_to_sentry("some message", {"extra": "context"}, level="debug")
mock_capture_event.assert_called_with(
{"message": "some message", "level": "debug"},
scope=None,
)

0 comments on commit 77626bd

Please sign in to comment.