mirror of
https://github.com/zulip/zulip.git
synced 2025-10-23 04:52:12 +00:00
sentry: Remove dependence on get_current_request.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
(cherry picked from commit f66e2c3112
)
This commit is contained in:
committed by
Alex Vandiver
parent
775d9a889c
commit
cc21dc8ec7
@@ -22,7 +22,7 @@ from django.utils.translation import gettext as _
|
||||
from django.views.csrf import csrf_failure as html_csrf_failure
|
||||
from django_scim.middleware import SCIMAuthCheckMiddleware
|
||||
from django_scim.settings import scim_settings
|
||||
from sentry_sdk import capture_exception
|
||||
from sentry_sdk import capture_exception, set_tag
|
||||
from sentry_sdk.integrations.logging import ignore_logger
|
||||
from typing_extensions import Concatenate, ParamSpec
|
||||
|
||||
@@ -296,6 +296,8 @@ class LogRequests(MiddlewareMixin):
|
||||
request_notes.client_name = "Unparsable"
|
||||
request_notes.client_version = None
|
||||
|
||||
set_tag("client", request_notes.client_name)
|
||||
|
||||
request_notes.log_data = {}
|
||||
record_request_start_data(request_notes.log_data)
|
||||
|
||||
@@ -563,6 +565,8 @@ class HostDomainMiddleware(MiddlewareMixin):
|
||||
|
||||
return render(request, "zerver/invalid_realm.html", status=404)
|
||||
|
||||
set_tag("realm", request_notes.realm.string_id)
|
||||
|
||||
# Check that we're not using the non-canonical form of a REALM_HOSTS subdomain
|
||||
if subdomain in settings.REALM_HOSTS:
|
||||
host = request.get_host().lower()
|
||||
|
@@ -24,7 +24,6 @@ def add_context(event: "Event", hint: "Hint") -> Optional["Event"]:
|
||||
return None
|
||||
from django.conf import settings
|
||||
|
||||
from zerver.lib.request import RequestNotes, get_current_request
|
||||
from zerver.models import get_user_profile_by_id
|
||||
|
||||
with capture_internal_exceptions():
|
||||
@@ -47,13 +46,6 @@ def add_context(event: "Event", hint: "Hint") -> Optional["Event"]:
|
||||
if "email" in user_info:
|
||||
del user_info["email"]
|
||||
|
||||
request = get_current_request()
|
||||
if request:
|
||||
request_notes = RequestNotes.get_notes(request)
|
||||
if request_notes.client is not None:
|
||||
event["tags"]["client"] = request_notes.client.name
|
||||
if request_notes.realm is not None:
|
||||
event["tags"].setdefault("realm", request_notes.realm.string_id)
|
||||
return event
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user