Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
sentry: Remove dependence on get_current_request.
Anders Kaseorgf66e2c31128d
diff --git a/zerver/middleware.py b/zerver/middleware.pyindex 30df1fcfb00..23348aae189 100644--- a/zerver/middleware.py+++ b/zerver/middleware.py@@ -22,7 +22,7 @@ from django.utils.translation import gettext as _from django.views.csrf import csrf_failure as html_csrf_failurefrom django_scim.middleware import SCIMAuthCheckMiddlewarefrom django_scim.settings import scim_settings-from sentry_sdk import capture_exception+from sentry_sdk import capture_exception, set_tagfrom sentry_sdk.integrations.logging import ignore_loggerfrom 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 subdomainif subdomain in settings.REALM_HOSTS:host = request.get_host().lower()diff --git a/zproject/sentry.py b/zproject/sentry.pyindex e889710e3cb..ff8850ddbfa 100644--- a/zproject/sentry.py+++ b/zproject/sentry.py@@ -24,7 +24,6 @@ def add_context(event: "Event", hint: "Hint") -> Optional["Event"]:return Nonefrom django.conf import settings- from zerver.lib.request import RequestNotes, get_current_requestfrom zerver.models import get_user_profile_by_idwith 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