Skip to content

Commit

Permalink
Refactor SentryReporter for better breadcrumb handling
Browse files Browse the repository at this point in the history
Improve the way breadcrumbs are handled in SentryReporter. Replace hardcoded 'breadcrumbs' string with a constant and use it to fetch event data. Also, ensure that breadcrumbs are ordered by UTC time, enhancing readability and consistency of event logs. Exception handling is maintained for any issues during this process.
  • Loading branch information
drew2a committed May 24, 2024
1 parent c05b62a commit 957b329
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/tribler/core/sentry_reporter/sentry_reporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,12 +387,11 @@ def _before_send(self, event: Optional[Dict], hint: Optional[Dict]) -> Optional[
event = self.scrubber.scrub_event(event)

# order breadcrumbs by timestamp in ascending order
if breadcrumbs := event.get('breadcrumbs'):
if breadcrumbs := event.get(BREADCRUMBS):
try:
event['breadcrumbs'] = order_by_utc_time(breadcrumbs)
event[BREADCRUMBS][VALUES] = order_by_utc_time(breadcrumbs[VALUES])
except Exception as e:
self._logger.exception(e)

return event

# pylint: disable=unused-argument
Expand Down

0 comments on commit 957b329

Please sign in to comment.