From 2d3fc8cb743d29ca5b5d49ce7559a9ff41a54170 Mon Sep 17 00:00:00 2001 From: Ivana Kellyer Date: Tue, 22 Jul 2025 09:07:52 +0200 Subject: [PATCH] ref(spotlight): Do not import sentry_sdk.spotlight unless enabled --- sentry_sdk/client.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sentry_sdk/client.py b/sentry_sdk/client.py index 979ea92906..dca39beab8 100644 --- a/sentry_sdk/client.py +++ b/sentry_sdk/client.py @@ -47,7 +47,6 @@ ) from sentry_sdk.scrubber import EventScrubber from sentry_sdk.monitor import Monitor -from sentry_sdk.spotlight import setup_spotlight if TYPE_CHECKING: from typing import Any @@ -429,6 +428,10 @@ def _capture_envelope(envelope): ) if self.options.get("spotlight"): + # This is intentionally here to prevent setting up spotlight + # stuff we don't need unless spotlight is explicitly enabled + from sentry_sdk.spotlight import setup_spotlight + self.spotlight = setup_spotlight(self.options) if not self.options["dsn"]: sample_all = lambda *_args, **_kwargs: 1.0