Skip to content
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

ref: Add max tries to Spotlight #2571

Merged
merged 2 commits into from
Dec 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 8 additions & 1 deletion sentry_sdk/spotlight.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,15 @@
# type: (str) -> None
self.url = url
self.http = urllib3.PoolManager()
self.tries = 0

Check warning on line 20 in sentry_sdk/spotlight.py

View check run for this annotation

Codecov / codecov/patch

sentry_sdk/spotlight.py#L20

Added line #L20 was not covered by tests

def capture_envelope(self, envelope):
# type: (Envelope) -> None
if self.tries > 3:
logger.warning(

Check warning on line 25 in sentry_sdk/spotlight.py

View check run for this annotation

Codecov / codecov/patch

sentry_sdk/spotlight.py#L25

Added line #L25 was not covered by tests
"Too many errors sending to Spotlight, stop sending events there."
)
return

Check warning on line 28 in sentry_sdk/spotlight.py

View check run for this annotation

Codecov / codecov/patch

sentry_sdk/spotlight.py#L28

Added line #L28 was not covered by tests
body = io.BytesIO()
envelope.serialize_into(body)
try:
Expand All @@ -33,7 +39,8 @@
)
req.close()
except Exception as e:
logger.exception(str(e))
self.tries += 1
logger.warning(str(e))

Check warning on line 43 in sentry_sdk/spotlight.py

View check run for this annotation

Codecov / codecov/patch

sentry_sdk/spotlight.py#L42-L43

Added lines #L42 - L43 were not covered by tests


def setup_spotlight(options):
Expand Down