From d5bf1724e3dac005b742c8b5d2a01c83965bb01f Mon Sep 17 00:00:00 2001 From: Devin Gaffney Date: Tue, 5 Sep 2023 08:40:17 -0700 Subject: [PATCH] add sentry as requirement for logging --- lib/http.py | 1 + lib/sentry.py | 9 +++++++++ requirements.txt | 3 ++- run_processor.py | 1 + run_worker.py | 1 + 5 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 lib/sentry.py diff --git a/lib/http.py b/lib/http.py index 6c9fc41..0707777 100644 --- a/lib/http.py +++ b/lib/http.py @@ -12,6 +12,7 @@ from lib.queue.worker import QueueWorker from lib.logger import logger from lib import schemas +from lib.sentry import sentry_sdk app = FastAPI() diff --git a/lib/sentry.py b/lib/sentry.py new file mode 100644 index 0000000..8804a1e --- /dev/null +++ b/lib/sentry.py @@ -0,0 +1,9 @@ +import os +import sentry_sdk +from lib.helpers import get_environment_setting + +sentry_sdk.init( + dsn=get_environment_setting('sentry_sdk_dsn'), + environment=get_environment_setting("DEPLOY_ENV"), + traces_sample_rate=1.0, +) diff --git a/requirements.txt b/requirements.txt index 867696e..946cb9c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -10,4 +10,5 @@ httpx==0.23.1 huggingface-hub==0.11.0 fasttext==0.9.2 requests==2.31.0 -pytest==7.4.0 \ No newline at end of file +pytest==7.4.0 +sentry-sdk==1.30.0 \ No newline at end of file diff --git a/run_processor.py b/run_processor.py index 960257c..e7c6ee9 100644 --- a/run_processor.py +++ b/run_processor.py @@ -4,6 +4,7 @@ from lib.queue.processor import QueueProcessor from lib.model.model import Model from lib.logger import logger +from lib.sentry import sentry_sdk queue = QueueProcessor.create() logger.info("Beginning callback loop...") diff --git a/run_worker.py b/run_worker.py index f4b7a27..fc7353e 100644 --- a/run_worker.py +++ b/run_worker.py @@ -4,6 +4,7 @@ from lib.queue.worker import QueueWorker from lib.model.model import Model from lib.logger import logger +from lib.sentry import sentry_sdk queue = QueueWorker.create() model = Model.create()