root: don't trace websockets to sentry
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
This commit is contained in:
parent
f70be86ddc
commit
d2cfb76a7c
|
@ -36,18 +36,6 @@ from authentik.lib.utils.reflection import class_to_path, get_env
|
|||
LOGGER = get_logger()
|
||||
|
||||
|
||||
class SentryWSMiddleware(BaseMiddleware):
|
||||
"""Sentry Websocket middleweare to set the transaction name based on
|
||||
consumer class path"""
|
||||
|
||||
async def __call__(self, scope, receive, send):
|
||||
transaction: Optional[Transaction] = Hub.current.scope.transaction
|
||||
class_path = class_to_path(self.inner.consumer_class)
|
||||
if transaction:
|
||||
transaction.name = class_path
|
||||
return await self.inner(scope, receive, send)
|
||||
|
||||
|
||||
class SentryIgnoredException(Exception):
|
||||
"""Base Class for all errors that are suppressed, and not sent to sentry."""
|
||||
|
||||
|
@ -94,9 +82,12 @@ def sentry_init(**sentry_init_kwargs):
|
|||
def traces_sampler(sampling_context: dict) -> float:
|
||||
"""Custom sampler to ignore certain routes"""
|
||||
path = sampling_context.get("asgi_scope", {}).get("path", "")
|
||||
_type = sampling_context.get("asgi_scope", {}).get("type", "")
|
||||
# Ignore all healthcheck routes
|
||||
if path.startswith("/-/health") or path.startswith("/-/metrics"):
|
||||
return 0
|
||||
if _type == "websocket":
|
||||
return 0
|
||||
return float(CONFIG.y("error_reporting.sample_rate", 0.1))
|
||||
|
||||
|
||||
|
|
|
@ -2,11 +2,10 @@
|
|||
from channels.auth import AuthMiddlewareStack
|
||||
from django.urls import path
|
||||
|
||||
from authentik.lib.sentry import SentryWSMiddleware
|
||||
from authentik.outposts.channels import OutpostConsumer
|
||||
from authentik.root.messages.consumer import MessageConsumer
|
||||
|
||||
websocket_urlpatterns = [
|
||||
path("ws/outpost/<uuid:pk>/", SentryWSMiddleware(OutpostConsumer.as_asgi())),
|
||||
path("ws/client/", AuthMiddlewareStack(SentryWSMiddleware(MessageConsumer.as_asgi()))),
|
||||
path("ws/outpost/<uuid:pk>/", OutpostConsumer.as_asgi()),
|
||||
path("ws/client/", AuthMiddlewareStack(MessageConsumer.as_asgi())),
|
||||
]
|
||||
|
|
Reference in New Issue