mirror of https://github.com/zulip/zulip.git
sentry: Do not report errors tlaking to Sentry, to Sentry.
This prevents failure to submit a client-side Sentry trace from turning into a server-side client trace. If Sentry is down, we merely log the error to our error logs and carry on.
This commit is contained in:
parent
f2f6f6c48c
commit
9519945dc0
|
@ -1,3 +1,4 @@
|
|||
import logging
|
||||
import urllib
|
||||
from contextlib import suppress
|
||||
|
||||
|
@ -6,11 +7,18 @@ from django.conf import settings
|
|||
from django.http import HttpRequest, HttpResponse
|
||||
from django.utils.translation import gettext as _
|
||||
from django.views.decorators.csrf import csrf_exempt
|
||||
from requests.exceptions import RequestException
|
||||
from sentry_sdk.integrations.logging import ignore_logger
|
||||
|
||||
from zerver.lib.exceptions import JsonableError
|
||||
from zerver.lib.outgoing_http import OutgoingSession
|
||||
from zerver.lib.validator import check_url, to_wild_value
|
||||
|
||||
# In order to not overload Sentry if it's having a bad day, we tell
|
||||
# Sentry to ignore exceptions that we have when talking to Sentry.
|
||||
logger = logging.getLogger(__name__)
|
||||
ignore_logger(logger.name)
|
||||
|
||||
|
||||
class SentryTunnelSession(OutgoingSession):
|
||||
def __init__(self) -> None:
|
||||
|
@ -74,7 +82,13 @@ def sentry_tunnel(
|
|||
parts.append(b"\n")
|
||||
updated_body = b"".join(parts)
|
||||
|
||||
SentryTunnelSession().post(
|
||||
url=url, data=updated_body, headers={"Content-Type": "application/x-sentry-envelope"}
|
||||
).raise_for_status()
|
||||
try:
|
||||
SentryTunnelSession().post(
|
||||
url=url,
|
||||
data=updated_body,
|
||||
headers={"Content-Type": "application/x-sentry-envelope"},
|
||||
).raise_for_status()
|
||||
except RequestException as e:
|
||||
# This logger has been configured, above, to not report to Sentry
|
||||
logger.exception(e)
|
||||
return HttpResponse(status=200)
|
||||
|
|
Loading…
Reference in New Issue