def test_get_func_no_module(self): func = mock.Mock() func.__name__ = 'test_func' func.__module__ = None func_name = utils.get_func_name(func) expected_func_name = 'test_func' self.assertEqual(func_name, expected_func_name)
def process_view(self, request, view_func, *args, **kwargs): """Process view is executed before the view function, here we get the function name add set it as the span name. """ # Do not trace if the url is excludelisted if utils.disable_tracing_url(request.path, self.excludelist_paths): return try: # Get the current span and set the span name to the current # function name of the request. tracer = _get_current_tracer() span = tracer.current_span() span.name = utils.get_func_name(view_func) except Exception: # pragma: NO COVER log.error('Failed to trace request', exc_info=True)
def get_span_name(self, request): return utils.get_func_name(request.resolver_match.func)