Skip to content

Commit a67bfa3

Browse files
committed
fix: add sentry monit
1 parent 51fd8a0 commit a67bfa3

File tree

4 files changed

+190
-4
lines changed

4 files changed

+190
-4
lines changed

controller/sentry/webservices/sentry.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def __call__(self, r):
2626
class PaginatedSentryClient(metaclass=Singleton):
2727
def __init__(self) -> None:
2828
self.host = "https://sentry.io/api/0/"
29-
self.auth = BearerAuth(settings.SENTRY_TOKEN)
29+
self.auth = BearerAuth(settings.SENTRY_API_TOKEN)
3030

3131
def __call(self, method: str, url):
3232
while True:

controller/settings.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from pathlib import Path
1515
from urllib.parse import quote
1616

17+
import sentry_sdk
1718
from celery.schedules import crontab
1819

1920
# Build paths inside the project like this: BASE_DIR / 'subdir'.
@@ -263,4 +264,17 @@
263264
}
264265

265266

266-
SENTRY_TOKEN = os.getenv("SENTRY_TOKEN")
267+
SENTRY_API_TOKEN = os.getenv("SENTRY_API_TOKEN", "TEST")
268+
SENTRY_DSN = os.getenv("SENTRY_DSN")
269+
270+
if SENTRY_DSN:
271+
from sentry_dynamic_sampling_lib import init_wrapper
272+
273+
ENVIRONMENT = os.getenv("ENV", "production")
274+
sentry_sdk.init(
275+
dsn="https://[email protected]/4504617124888576",
276+
environment=ENVIRONMENT,
277+
)
278+
279+
# hook sentry_dynamic_sampling_lib into sentry
280+
init_wrapper()

poetry.lock

Lines changed: 172 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ undecorated = "^0.3.0"
2727
django-health-check = "^3.17.0"
2828
celery = "^5.2.7"
2929
django-celery-results = "^2.4.0"
30+
sentry-dynamic-sampling-lib = "^1.1.3"
31+
sentry-sdk = "^1.14.0"
3032

3133

3234
[tool.poetry.group.dev.dependencies]

0 commit comments

Comments
 (0)