From 7a1fd396a56648eb365ccd221ae17aa89b62219a Mon Sep 17 00:00:00 2001 From: Mark Murnane Date: Wed, 2 Aug 2023 04:15:18 -0400 Subject: [PATCH 1/3] Adding sentry hooks --- requirements.txt | 1 + uber/config.py | 1 + uber/configspec.ini | 4 ++++ uber/server.py | 10 ++++++++++ 4 files changed, 16 insertions(+) diff --git a/requirements.txt b/requirements.txt index d3b1559d9..f6eaea92a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -31,3 +31,4 @@ pyyaml==6.0 pycountry==22.3.5 python3-saml==1.15.0 librabbitmq +sentry-sdk \ No newline at end of file diff --git a/uber/config.py b/uber/config.py index 374554ce3..2acf82550 100644 --- a/uber/config.py +++ b/uber/config.py @@ -986,6 +986,7 @@ def _unrepr(d): _unrepr(_config['appconf']) c.APPCONF = _config['appconf'].dict() +c.SENTRY = _config['sentry'].dict() c.BADGE_PRICES = _config['badge_prices'] for _opt, _val in chain(_config.items(), c.BADGE_PRICES.items()): diff --git a/uber/configspec.ini b/uber/configspec.ini index 53aa575b6..970031bfc 100644 --- a/uber/configspec.ini +++ b/uber/configspec.ini @@ -1830,6 +1830,10 @@ __many__ = string(default="") [celery] # Celery configuration, except for broker_url which can be found in [secret] +[sentry] +enabled = boolean(default=False) +dsn = string +sample_rate = integer(default=100) [appconf] # This is all CherryPy configuration. diff --git a/uber/server.py b/uber/server.py index a0fefd43a..cf3836947 100644 --- a/uber/server.py +++ b/uber/server.py @@ -22,6 +22,16 @@ mimetypes.init() +if c.SENTRY['enabled']: + import sentry_sdk + sentry_sdk.init( + dsn=c.SENTRY['dsn'], + + # Set traces_sample_rate to 1.0 to capture 100% + # of transactions for performance monitoring. + # We recommend adjusting this value in production. + traces_sample_rate=c.SENTRY['sample_rate'] / 100 + ) def _add_email(): [body] = cherrypy.response.body From 8a74349450f16fa77656a39c262beefa6162da0c Mon Sep 17 00:00:00 2001 From: Mark Murnane Date: Wed, 2 Aug 2023 04:23:16 -0400 Subject: [PATCH 2/3] Adding release and environment sentry settings --- uber/configspec.ini | 2 ++ uber/server.py | 2 ++ 2 files changed, 4 insertions(+) diff --git a/uber/configspec.ini b/uber/configspec.ini index 970031bfc..e30ac4228 100644 --- a/uber/configspec.ini +++ b/uber/configspec.ini @@ -1833,7 +1833,9 @@ __many__ = string(default="") [sentry] enabled = boolean(default=False) dsn = string +environment = string(default="production") sample_rate = integer(default=100) +release = string [appconf] # This is all CherryPy configuration. diff --git a/uber/server.py b/uber/server.py index cf3836947..6ff01bf34 100644 --- a/uber/server.py +++ b/uber/server.py @@ -26,6 +26,8 @@ import sentry_sdk sentry_sdk.init( dsn=c.SENTRY['dsn'], + environment=c.SENTRY['environment'], + release=c.SENTRY['release'], # Set traces_sample_rate to 1.0 to capture 100% # of transactions for performance monitoring. From 0f55f5e22dea97fce8d90be8d2fe89c34ae79c94 Mon Sep 17 00:00:00 2001 From: Mark Murnane Date: Wed, 2 Aug 2023 20:01:26 -0400 Subject: [PATCH 3/3] Pinning all versions --- requirements.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/requirements.txt b/requirements.txt index f6eaea92a..ed34caa42 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,7 @@ cherrypy==17.3.0 -celery +celery==5.1.2 python-dateutil==2.6.0 -psycopg2 +psycopg2==2.9.6 py3k-bcrypt==0.3 stripe==2.42.0 authorizenet==1.1.4 @@ -30,5 +30,5 @@ WTForms==3.0.0 pyyaml==6.0 pycountry==22.3.5 python3-saml==1.15.0 -librabbitmq -sentry-sdk \ No newline at end of file +librabbitmq==2.0.0 +sentry-sdk==1.9.0 \ No newline at end of file