Skip to content

Commit

Permalink
Merge pull request #7365 from drew2a/feature/add_stop_on_close
Browse files Browse the repository at this point in the history
Add `tribler_stopped` tag to the Sentry
  • Loading branch information
drew2a authored Apr 14, 2023
2 parents 7e6cb60 + 171f02d commit f43d795
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/tribler/core/sentry_reporter/sentry_reporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from contextvars import ContextVar
from enum import Enum, auto
from hashlib import md5
from typing import Dict, List, Optional
from typing import Any, Dict, List, Optional

import sentry_sdk
from faker import Faker
Expand Down Expand Up @@ -147,7 +147,7 @@ def add_breadcrumb(self, message='', category='', level='info', **kwargs):
return sentry_sdk.add_breadcrumb(crumb, **kwargs)

def send_event(self, event: Dict = None, post_data: Dict = None, sys_info: Dict = None,
additional_tags: List[str] = None, last_core_output: Optional[str] = None,
additional_tags: Dict[str, Any] = None, last_core_output: Optional[str] = None,
last_processes: List[str] = None):
"""Send the event to the Sentry server
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ def test_send_sys_info(sentry_reporter):


def test_send_additional_tags(sentry_reporter):
actual = sentry_reporter.send_event(event={}, additional_tags={'tag_key': 'tag_value'})
actual = sentry_reporter.send_event(event={}, additional_tags={'tag_key': 'tag_value', 'numeric_tag_key': 1})
expected = {
'contexts': {
'browser': {'name': 'Tribler', 'version': None},
Expand All @@ -286,6 +286,7 @@ def test_send_additional_tags(sentry_reporter):
'platform.details': None,
'version': None,
'tag_key': 'tag_value',
'numeric_tag_key': 1,
},
}
assert actual == expected
Expand Down
14 changes: 12 additions & 2 deletions src/tribler/gui/error_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,19 @@ def gui_error(self, exc_type, exc, tb):
if self.app_manager.quitting_app:
return

additional_tags = {
'source': 'gui',
'tribler_stopped': self._tribler_stopped
}

FeedbackDialog(
parent=self.tribler_window,
sentry_reporter=gui_sentry_reporter,
reported_error=reported_error,
tribler_version=self.tribler_window.tribler_version,
start_time=self.tribler_window.start_time,
stop_application_on_close=self._tribler_stopped,
additional_tags={'source': 'gui'},
additional_tags=additional_tags,
).show()

def core_error(self, reported_error: ReportedError):
Expand All @@ -99,14 +104,19 @@ def core_error(self, reported_error: ReportedError):

SentryScrubber.remove_breadcrumbs(reported_error.event)

additional_tags = {
'source': 'core',
'tribler_stopped': self._tribler_stopped
}

FeedbackDialog(
parent=self.tribler_window,
sentry_reporter=gui_sentry_reporter,
reported_error=reported_error,
tribler_version=self.tribler_window.tribler_version,
start_time=self.tribler_window.start_time,
stop_application_on_close=self._tribler_stopped,
additional_tags={'source': 'core'}
additional_tags=additional_tags,
).show()

def _stop_tribler(self, text):
Expand Down

0 comments on commit f43d795

Please sign in to comment.