Skip to content

feat: Do not spam sentry_sdk.warnings logger w/ Spotlight #4219

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 1, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions sentry_sdk/spotlight.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def __init__(self, url):
# type: (str) -> None
self.url = url
self.http = urllib3.PoolManager()
self.tries = 0
self.fails = 0

def capture_envelope(self, envelope):
# type: (Envelope) -> None
Expand All @@ -54,9 +54,18 @@ def capture_envelope(self, envelope):
},
)
req.close()
self.fails = 0
except Exception as e:
# TODO: Implement buffering and retrying with exponential backoff
sentry_logger.warning(str(e))
if self.fails < 2:
sentry_logger.warning(str(e))
self.fails += 1
elif self.fails == 2:
self.fails += 1
sentry_logger.warning(
"Looks like Spotlight is not running, will keep trying to send events but will not log errors."
)
# omitting self.fails += 1 in the `else:` case intentionally
# to avoid overflowing the variable if Spotlight never becomes reachable


try:
Expand Down
Loading