mirror of https://github.com/zulip/zulip.git
sentry: Remove dependence on get_current_request.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
parent
59e78f96ba
commit
f66e2c3112
|
@ -22,7 +22,7 @@ from django.utils.translation import gettext as _
|
||||||
from django.views.csrf import csrf_failure as html_csrf_failure
|
from django.views.csrf import csrf_failure as html_csrf_failure
|
||||||
from django_scim.middleware import SCIMAuthCheckMiddleware
|
from django_scim.middleware import SCIMAuthCheckMiddleware
|
||||||
from django_scim.settings import scim_settings
|
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 sentry_sdk.integrations.logging import ignore_logger
|
||||||
from typing_extensions import Concatenate, ParamSpec
|
from typing_extensions import Concatenate, ParamSpec
|
||||||
|
|
||||||
|
@ -296,6 +296,8 @@ class LogRequests(MiddlewareMixin):
|
||||||
request_notes.client_name = "Unparsable"
|
request_notes.client_name = "Unparsable"
|
||||||
request_notes.client_version = None
|
request_notes.client_version = None
|
||||||
|
|
||||||
|
set_tag("client", request_notes.client_name)
|
||||||
|
|
||||||
request_notes.log_data = {}
|
request_notes.log_data = {}
|
||||||
record_request_start_data(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)
|
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
|
# Check that we're not using the non-canonical form of a REALM_HOSTS subdomain
|
||||||
if subdomain in settings.REALM_HOSTS:
|
if subdomain in settings.REALM_HOSTS:
|
||||||
host = request.get_host().lower()
|
host = request.get_host().lower()
|
||||||
|
|
|
@ -24,7 +24,6 @@ def add_context(event: "Event", hint: "Hint") -> Optional["Event"]:
|
||||||
return None
|
return None
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
|
||||||
from zerver.lib.request import RequestNotes, get_current_request
|
|
||||||
from zerver.models import get_user_profile_by_id
|
from zerver.models import get_user_profile_by_id
|
||||||
|
|
||||||
with capture_internal_exceptions():
|
with capture_internal_exceptions():
|
||||||
|
@ -47,13 +46,6 @@ def add_context(event: "Event", hint: "Hint") -> Optional["Event"]:
|
||||||
if "email" in user_info:
|
if "email" in user_info:
|
||||||
del user_info["email"]
|
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
|
return event
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue