Skip to content

Commit

Permalink
Merge pull request #577 from oda-hub/missing-sentry-client-init
Browse files Browse the repository at this point in the history
sentry init was never executed
  • Loading branch information
burnout87 authored Aug 30, 2023
2 parents f8e6a90 + 725583b commit 175c9f1
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions cdci_data_analysis/flask_app/sentry.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
import sentry_sdk
import os

logger = logging.getLogger(__name__)
# logger = logging.getLogger(__name__)

class Sentry:
def __init__(self) -> None:
self._app = None
self.logger = logging.getLogger(repr(self))

@property
def app(self):
Expand All @@ -26,6 +27,7 @@ def sentry_url(self):

return self._sentry_url

@property
def have_sentry(self):
if self.sentry_url is None:
return False
Expand All @@ -42,17 +44,16 @@ def have_sentry(self):
environment=getattr(self.app.config.get('conf'), 'sentry_environment', 'production')
)
except Exception as e:
logger.warning("can not setup sentry with URL %s due to %s", self.sentry_url, e)
self.logger.warning("can not setup sentry with URL %s due to %s", self.sentry_url, e)

return True

def capture_message(self, message: str, logger=None):
def capture_message(self, message: str):
if self.have_sentry:
if logger is not None:
logger.warning(message)
self.logger.warning(message)

sentry_sdk.capture_message(message)
else:
logger.warning("sentry not used, dropping %s", message)
self.logger.warning("sentry not used, dropping %s", message)

sentry = Sentry()

0 comments on commit 175c9f1

Please sign in to comment.