don't use sentry in tests
change
commit 51f969c71d11ac9201106da69c01c42f60407650
author Alpha Chen <alpha@kejadlen.dev>
date
parent 1f2f13f0
diff --git a/go_ji/__init__.py b/go_ji/__init__.py
index 8ef2583..5477d6a 100644
--- a/go_ji/__init__.py
+++ b/go_ji/__init__.py
@@ -16,18 +16,6 @@ config = Config("")
 config["DB_URL"] = "sqlite:///go-ji.db"
 config.from_prefixed_env("GO_JI")
 
-sentry_sdk.init(
-    dsn=config["SENTRY_DSN"],
-    environment=config["SENTRY_ENVIRONMENT"],
-    # Set traces_sample_rate to 1.0 to capture 100%
-    # of transactions for performance monitoring.
-    traces_sample_rate=1.0,
-    # Set profiles_sample_rate to 1.0 to profile 100%
-    # of sampled transactions.
-    # We recommend adjusting this value in production.
-    profiles_sample_rate=1.0,
-)
-
 
 def create_app(config_override: dict[str, Any] = {}) -> Flask:
     app = Flask(__name__, instance_relative_config=True)
@@ -35,6 +23,19 @@ def create_app(config_override: dict[str, Any] = {}) -> Flask:
     app.config.from_mapping(config)
     app.config.from_mapping(config_override)
 
+    if "TESTING" not in app.config:
+        sentry_sdk.init(
+            dsn=app.config["SENTRY_DSN"],
+            environment=app.config["SENTRY_ENVIRONMENT"],
+            # Set traces_sample_rate to 1.0 to capture 100%
+            # of transactions for performance monitoring.
+            traces_sample_rate=1.0,
+            # Set profiles_sample_rate to 1.0 to profile 100%
+            # of sampled transactions.
+            # We recommend adjusting this value in production.
+            profiles_sample_rate=1.0,
+        )
+
     # set up db
     db_session = create_db_session(app.config["DB_URL"])