def sentry_patched_get_response(self, request): # type: (Any, WSGIRequest) -> Union[HttpResponse, BaseException] hub = Hub.current integration = hub.get_integration(DjangoIntegration) if integration is not None: _patch_drf() with hub.configure_scope() as scope: # Rely on WSGI middleware to start a trace try: if integration.transaction_style == "function_name": scope.transaction = transaction_from_function( resolve(request.path).func) elif integration.transaction_style == "url": scope.transaction = LEGACY_RESOLVER.resolve( request.path) except Exception: pass scope.add_event_processor( _make_event_processor(weakref.ref(request), integration)) return old_get_response(self, request)
def _before_get_response(request): # type: (WSGIRequest) -> None hub = Hub.current integration = hub.get_integration(DjangoIntegration) if integration is None: return _patch_drf() with hub.configure_scope() as scope: # Rely on WSGI middleware to start a trace try: if integration.transaction_style == "function_name": fn = resolve(request.path).func scope.transaction = transaction_from_function( getattr(fn, "view_class", fn)) elif integration.transaction_style == "url": scope.transaction = LEGACY_RESOLVER.resolve(request.path_info) except Exception: pass scope.add_event_processor( _make_event_processor(weakref.ref(request), integration))
async def sentry_urldispatcher_resolve(self, request): # type: (UrlDispatcher, Request) -> AbstractMatchInfo rv = await old_urldispatcher_resolve(self, request) hub = Hub.current integration = hub.get_integration(AioHttpIntegration) name = None try: if integration.transaction_style == "handler_name": name = transaction_from_function(rv.handler) elif integration.transaction_style == "method_and_path_pattern": route_info = rv.get_info() pattern = route_info.get("path") or route_info.get("formatter") name = "{} {}".format(request.method, pattern) except Exception: pass if name is not None: with Hub.current.configure_scope() as scope: scope.transaction = name return rv
def get_transaction(self, scope): # type: (Any) -> Optional[str] """ Return a transaction string to identify the routed endpoint. """ return transaction_from_function(scope["endpoint"])
def get_transaction(self, scope): """ Return a transaction string to identify the routed endpoint. """ return transaction_from_function(scope["endpoint"])
def get_transaction(scope): return transaction_from_function(scope["endpoint"])