From f1d280cfc918c730f6b55841743ccae90e2bdd83 Mon Sep 17 00:00:00 2001
From: David Douard <david.douard@sdfa3.org>
Date: Tue, 20 Aug 2024 10:42:20 +0200
Subject: [PATCH] Make sentry init with no DSN silent by default

Having the unavoidable warning about sentry not sending event in any cli
call is not great. Make it silent by default.
---
 swh/core/cli/__init__.py | 3 +--
 swh/core/sentry.py       | 2 +-
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/swh/core/cli/__init__.py b/swh/core/cli/__init__.py
index 1c9cc84..1103a4f 100644
--- a/swh/core/cli/__init__.py
+++ b/swh/core/cli/__init__.py
@@ -141,9 +141,8 @@ def swh(ctx, log_levels, log_config, sentry_dsn, sentry_debug):
     signal.signal(signal.SIGTERM, clean_exit_on_signal)
     signal.signal(signal.SIGINT, clean_exit_on_signal)
 
-    init_sentry(sentry_dsn=sentry_dsn, debug=sentry_debug)
-
     set_default_loglevel = logging_configure(log_levels, log_config)
+    init_sentry(sentry_dsn=sentry_dsn, debug=sentry_debug)
 
     ctx.ensure_object(dict)
     ctx.obj["log_level"] = set_default_loglevel
diff --git a/swh/core/sentry.py b/swh/core/sentry.py
index 39ad431..68bba8f 100644
--- a/swh/core/sentry.py
+++ b/swh/core/sentry.py
@@ -82,7 +82,7 @@ def init_sentry(
     )
 
     if sentry_dsn is None and not deferred_init:
-        logger.warning("Sentry DSN not provided, events will not be sent.")
+        logger.info("Sentry DSN not provided, events will not be sent.")
 
     import sentry_sdk
 
-- 
GitLab