Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Make sentry settings configurable (#8245)
Tomasz Szymański53bcf03c8da4
diff --git a/saleor/core/app.py b/saleor/core/app.pyindex a9c2d66fc2..75fb991ac5 100644--- a/saleor/core/app.py+++ b/saleor/core/app.py@@ -1,4 +1,5 @@from django.apps import AppConfig+from django.conf import settingsfrom django.db.models import Fieldfrom .db.filters import PostgresILike@@ -9,3 +10,6 @@ class CoreAppConfig(AppConfig):def ready(self):Field.register_lookup(PostgresILike)++ if settings.SENTRY_DSN:+ settings.SENTRY_INIT(settings.SENTRY_DSN, settings.SENTRY_OPTS)diff --git a/saleor/demo/settings.py b/saleor/demo/settings.pyindex 70a58a7bb0..7a131d741d 100644--- a/saleor/demo/settings.py+++ b/saleor/demo/settings.py@@ -17,6 +17,7 @@ import loggingimport refrom sentry_sdk.integrations.celery import CeleryIntegration+from sentry_sdk.integrations.logging import ignore_loggerfrom ..settings import * # noqa: F403, lgtm [py/polluting-import]@@ -85,3 +86,4 @@ if DEMO_SENTRY_DSN:integrations=[CeleryIntegration(), DjangoIntegration()],before_send=before_send,)+ ignore_logger("graphql.execution.utils")diff --git a/saleor/settings.py b/saleor/settings.pyindex 2ba71412c8..730f65ddcf 100644--- a/saleor/settings.py+++ b/saleor/settings.py@@ -502,12 +502,19 @@ DEFAULT_CHANNEL_SLUG = os.environ.get("DEFAULT_CHANNEL_SLUG", "default-channel")# Sentrysentry_sdk.utils.MAX_STRING_LENGTH = 4096SENTRY_DSN = os.environ.get("SENTRY_DSN")-if SENTRY_DSN:- sentry_sdk.init(- dsn=SENTRY_DSN, integrations=[CeleryIntegration(), DjangoIntegration()]- )+SENTRY_OPTS = {"integrations": [CeleryIntegration(), DjangoIntegration()]}+++def SENTRY_INIT(dsn: str, sentry_opts: dict):+ """Init function for sentry.++ Will only be called if SENTRY_DSN is not None, during core start, can be+ overriden in separate settings file.+ """+ sentry_sdk.init(dsn, **sentry_opts)ignore_logger("graphql.execution.utils")+GRAPHENE = {"RELAY_CONNECTION_ENFORCE_FIRST_OR_LAST": True,"RELAY_CONNECTION_MAX_LIMIT": 100,