def instrument_django_core_handlers_wsgi(module): # Wrap the WSGI application entry point. If this is also # wrapped from the WSGI script file or by the WSGI hosting # mechanism then those will take precedence. import django framework = ('Django', django.get_version()) module.WSGIHandler.__call__ = WSGIApplicationWrapper( module.WSGIHandler.__call__, framework=framework) # Wrap handle_uncaught_exception() of WSGIHandler so that # can capture exception details of any exception which # wasn't caught and dealt with by an exception middleware. # The handle_uncaught_exception() function produces a 500 # error response page and otherwise suppresses the # exception, so last chance to do this as exception will not # propagate up to the WSGI application. if hasattr(module.WSGIHandler, 'handle_uncaught_exception'): module.WSGIHandler.handle_uncaught_exception = ( wrap_handle_uncaught_exception( module.WSGIHandler.handle_uncaught_exception))
def wrapper_WSGIServer___init__(*args, **kwargs): def _bind_params(self, listener, application, *args, **kwargs): return self, listener, application, args, kwargs self, listener, application, _args, _kwargs = _bind_params( *args, **kwargs) application = WSGIApplicationWrapper(application) _args = (self, listener, application) + _args return _args, _kwargs
def _nr_wrapper_Application_wsgi_(application): # Normally Application.wsgi() returns a WSGI application, but in # some async frameworks a special class or coroutine is returned. We must # check for those cases and avoid insturmenting the coroutine or # specialized class. try: if 'tornado.web' in sys.modules: import tornado.web if isinstance(application, tornado.web.Application): return application except ImportError: pass if is_coroutine(application): return application elif (hasattr(application, '__call__') and is_coroutine(application.__call__)): return application else: return WSGIApplicationWrapper(application)
def wrap_wsgi_application_entry_point(server, application, **kwargs): return (( server, WSGIApplicationWrapper(application, framework='Django'), ), kwargs)