def instrument_cherrypy__cpdispatch(module): wrap_function_wrapper(module, 'Dispatcher.find_handler', wrapper_Dispatcher_find_handler) wrap_function_wrapper(module, 'RoutesDispatcher.find_handler', wrapper_RoutesDispatcher_find_handler) wrap_error_trace(module, 'PageHandler.__call__', ignore_errors=should_ignore)
def instrument_cherrypy__cpdispatch(module): wrap_function_wrapper(module, "Dispatcher.find_handler", wrapper_Dispatcher_find_handler) wrap_function_wrapper(module, "RoutesDispatcher.find_handler", wrapper_RoutesDispatcher_find_handler) wrap_error_trace(module, "PageHandler.__call__", ignore=["cherrypy._cperror:InternalRedirect"], status_code=status_code)
def instrument_django_core_urlresolvers(module): # Wrap method which maps a string version of a function # name as used in urls.py pattern so can capture any # exception which is raised during that process. # Normally Django captures import errors at this point # and then reraises a ViewDoesNotExist exception with # details of the original error and traceback being # lost. We thus intercept it here so can capture that # traceback which is otherwise lost. Although we ignore # a Http404 exception here, it probably is never the # case that one can be raised by get_callable(). wrap_error_trace(module, 'get_callable', ignore_errors=should_ignore) # Wrap methods which resolves a request to a view handler. # This can be called against a resolver initialised against # a custom URL conf associated with a specific request, or a # resolver which uses the default URL conf. if hasattr(module, 'RegexURLResolver'): urlresolver = module.RegexURLResolver else: urlresolver = module.URLResolver urlresolver.resolve = wrap_url_resolver(urlresolver.resolve) # Wrap methods which resolve error handlers. For 403 and 404 # we give these higher naming priority over any prior # middleware or view handler to give them visibility. For a # 500, which will be triggered for unhandled exception, we # leave any original name derived from a middleware or view # handler in place so error details identify the correct # transaction. if hasattr(urlresolver, 'resolve403'): urlresolver.resolve403 = wrap_url_resolver_nnn(urlresolver.resolve403, priority=3) if hasattr(urlresolver, 'resolve404'): urlresolver.resolve404 = wrap_url_resolver_nnn(urlresolver.resolve404, priority=3) if hasattr(urlresolver, 'resolve500'): urlresolver.resolve500 = wrap_url_resolver_nnn(urlresolver.resolve500, priority=1) if hasattr(urlresolver, 'resolve_error_handler'): urlresolver.resolve_error_handler = wrap_url_resolver_nnn( urlresolver.resolve_error_handler, priority=1) # Wrap function for performing reverse URL lookup to strip any # instrumentation wrapper when view handler is passed in. if hasattr(module, 'reverse'): module.reverse = wrap_url_reverse(module.reverse)
def instrument_django_core_urlresolvers(module): # Wrap method which maps a string version of a function # name as used in urls.py pattern so can capture any # exception which is raised during that process. # Normally Django captures import errors at this point # and then reraises a ViewDoesNotExist exception with # details of the original error and traceback being # lost. We thus intercept it here so can capture that # traceback which is otherwise lost. Although we ignore # a Http404 exception here, it probably is never the # case that one can be raised by get_callable(). wrap_error_trace(module, 'get_callable', ignore_errors=[ 'django.http:Http404', 'django.http.response:Http404']) # Wrap methods which resolves a request to a view handler. # This can be called against a resolver initialised against # a custom URL conf associated with a specific request, or a # resolver which uses the default URL conf. module.RegexURLResolver.resolve = wrap_url_resolver( module.RegexURLResolver.resolve) # Wrap methods which resolve error handlers. For 403 and 404 # we give these higher naming priority over any prior # middleware or view handler to give them visibility. For a # 500, which will be triggered for unhandled exception, we # leave any original name derived from a middleware or view # handler in place so error details identify the correct # transaction. if hasattr(module.RegexURLResolver, 'resolve403'): module.RegexURLResolver.resolve403 = wrap_url_resolver_nnn( module.RegexURLResolver.resolve403, priority=3) module.RegexURLResolver.resolve404 = wrap_url_resolver_nnn( module.RegexURLResolver.resolve404, priority=3) module.RegexURLResolver.resolve500 = wrap_url_resolver_nnn( module.RegexURLResolver.resolve500, priority=1) # Wrap function for performing reverse URL lookup to strip any # instrumentation wrapper when view handler is passed in. module.reverse = wrap_url_reverse(module.reverse)