diff --git a/boofilsic/settings.py b/boofilsic/settings.py index 3b31bfdd..182d31e1 100644 --- a/boofilsic/settings.py +++ b/boofilsic/settings.py @@ -1,4 +1,5 @@ import os +import sys import environ from django.utils.translation import gettext_lazy as _ @@ -102,6 +103,7 @@ env = environ.FileAwareEnv( # SSL only, better be True for production security SSL_ONLY=(bool, False), NEODB_SENTRY_DSN=(str, ""), + NEODB_SENTRY_SAMPLE_RATE=(float, 0), NEODB_FANOUT_LIMIT_DAYS=(int, 9), ) @@ -564,10 +566,14 @@ if SENTRY_DSN: from sentry_sdk.integrations.django import DjangoIntegration from sentry_sdk.integrations.loguru import LoguruIntegration + sentry_env = sys.argv[0].split("/")[-1] + if len(sys.argv) > 1 and sentry_env in ("manage.py", "django-admin"): + sentry_env = sys.argv[1] sentry_sdk.init( dsn=SENTRY_DSN, + environment=sentry_env or "unknown", integrations=[LoguruIntegration(), DjangoIntegration()], release=NEODB_VERSION, send_default_pii=True, - traces_sample_rate=1 if DEBUG else 0.001, + traces_sample_rate=env("NEODB_SENTRY_SAMPLE_RATE"), ) diff --git a/compose.yml b/compose.yml index 5ff68bd3..de1eed01 100644 --- a/compose.yml +++ b/compose.yml @@ -36,6 +36,7 @@ x-shared: NEODB_MIN_MARKS_FOR_DISCOVER: NEODB_SENTRY_DSN: TAKAHE_SENTRY_DSN: + NEODB_SENTRY_SAMPLE_RATE: NEODB_DB_URL: ${NEODB_DB_URL:-postgres://neodb:aubergine@neodb-db/neodb} TAKAHE_DB_URL: ${TAKAHE_DB_URL:-postgres://takahe:aubergine@takahe-db/takahe} NEODB_REDIS_URL: ${NEODB_REDIS_URL:-redis://redis:6379/0}