def wrap_elasticsearch_client_method(owner, name, arg_extractor, prefix=None): def _bw_wrapper_Elasticsearch_method_(wrapped, instance, args, kwargs): transaction = current_transaction() if transaction is None: return wrapped(*args, **kwargs) # When arg_extractor is None, it means there is no target field # associated with this method. Hence this method will only # create an operation metric and no statement metric. This is # handled by setting the target to None when calling the # DatastoreTrace. if arg_extractor is None: index = None else: index = arg_extractor(*args, **kwargs) if prefix: operation = '%s.%s' % (prefix, name) else: operation = name with DatastoreTrace(transaction, product='Elasticsearch', target=index, operation=operation): return wrapped(*args, **kwargs) if hasattr(owner, name): wrap_function_wrapper(owner, name, _bw_wrapper_Elasticsearch_method_)
def wrap_elasticsearch_client_method(module, name, arg_extractor): def _bw_wrapper_ElasticSearch_method_(wrapped, instance, args, kwargs): transaction = current_transaction() if transaction is None: return wrapped(*args, **kwargs) # When arg_extractor is None, it means there is no target field # associated with this method. Hence this method will only # create an operation metric and no statement metric. This is # handled by setting the target to None when calling the # DatastoreTrace. if arg_extractor is None: index = None else: index = arg_extractor(*args, **kwargs) with DatastoreTrace(transaction, product='Elasticsearch', target=index, operation=name): return wrapped(*args, **kwargs) if hasattr(module.ElasticSearch, name): wrap_function_wrapper(module.ElasticSearch, name, _bw_wrapper_ElasticSearch_method_)
def instrument_tornado_iostream(module): if hasattr(module, 'BaseIOStream'): wrap_function_wrapper(module, 'BaseIOStream._maybe_run_close_callback', maybe_run_close_callback_wrapper) elif hasattr(module.IOStream, '_maybe_run_close_callback'): wrap_function_wrapper(module, 'IOStream._maybe_run_close_callback', maybe_run_close_callback_wrapper)
def instrument_openerp_service_wsgi_server(module): # Wrap wsgi application. wrap_wsgi_application(module, 'application') # Before the wrapped wsgi application called , filter the longpolling # request which correspond to url /longpolling/poll by set the environ # value blueware.ignore_transaction to True to ignore this transaction. wrap_function_wrapper(module, 'application', _bw_wrapper_applictation)
def instrument_urllib3_connection(module): # Don't combine the instrument functions into a single function. Keep # the 'connect' monkey patch separate, because it is also used to patch # urllib3 within the requests package. wrap_function_wrapper(module, 'HTTPConnection.connect', functools.partial(httplib_connect_wrapper, scheme='http')) wrap_function_wrapper(module, 'HTTPSConnection.connect', functools.partial(httplib_connect_wrapper, scheme='https'))
def instrument_tornado_gen(module): # The Return class type was introduced in Tornado 3.0. global GeneratorReturn if hasattr(module, 'Return'): GeneratorReturn = module.Return # The gen.coroutine decorator was introduced in Tornado 3.0. if hasattr(module, 'coroutine'): wrap_function_wrapper(module, 'coroutine', _bw_wrapper_gen_coroutine_) # The gen.engine decorator, Runner class type and Task class type # were introduced in Tornado 2.0. if hasattr(module, 'engine'): wrap_function_wrapper(module, 'engine', _bw_wrapper_gen_coroutine_) if hasattr(module, 'Runner'): wrap_function_wrapper(module, 'Runner.__init__', _bw_wrapper_gen_Runner___init___) if hasattr(module, 'Task'): if hasattr(module.Task, 'start'): # The start() method was removed in Tornado 4.0. wrap_function_wrapper(module, 'Task.start', _bw_wrapper_Task_start_)
def instrument_bottle(module): global module_bottle module_bottle = module framework_details = ('Bottle', getattr(module, '__version__')) if hasattr(module.Bottle, 'wsgi'): # version >= 0.9 wrap_wsgi_application(module, 'Bottle.wsgi', framework=framework_details) elif hasattr(module.Bottle, '__call__'): # version < 0.9 wrap_wsgi_application(module, 'Bottle.__call__', framework=framework_details) if (hasattr(module, 'Route') and hasattr(module.Route, '_make_callback')): # version >= 0.10 wrap_out_function(module, 'Route._make_callback', output_wrapper_Route_make_callback) elif hasattr(module.Bottle, '_match'): # version >= 0.9 wrap_out_function(module, 'Bottle._match', output_wrapper_Bottle_match) elif hasattr(module.Bottle, 'match_url'): # version < 0.9 wrap_out_function(module, 'Bottle.match_url', output_wrapper_Bottle_match) wrap_object_attribute(module, 'Bottle.error_handler', proxy_Bottle_error_handler) if hasattr(module, 'auth_basic'): wrap_function_wrapper(module, 'auth_basic', wrapper_auth_basic) if hasattr(module, 'SimpleTemplate'): wrap_function_trace(module, 'SimpleTemplate.render') if hasattr(module, 'MakoTemplate'): wrap_function_trace(module, 'MakoTemplate.render') if hasattr(module, 'CheetahTemplate'): wrap_function_trace(module, 'CheetahTemplate.render') if hasattr(module, 'Jinja2Template'): wrap_function_trace(module, 'Jinja2Template.render') if hasattr(module, 'SimpleTALTemplate'): wrap_function_trace(module, 'SimpleTALTemplate.render')
def instrument_gearman_connection_manager(module): wrap_function_wrapper(module, 'GearmanConnectionManager.handle_read', wrapper_GearmanConnectionManager_handle_function) wrap_function_wrapper(module, 'GearmanConnectionManager.handle_write', wrapper_GearmanConnectionManager_handle_function) wrap_function_wrapper(module, 'GearmanConnectionManager.handle_error', wrapper_GearmanConnectionManager_handle_function) wrap_function_wrapper(module, 'GearmanConnectionManager.poll_connections_until_stopped', wrapper_GearmanConnectionManager_poll_connections_until_stopped)
def instrument_gearman_connection_manager(module): wrap_function_wrapper(module, 'GearmanConnectionManager.handle_read', wrapper_GearmanConnectionManager_handle_function) wrap_function_wrapper(module, 'GearmanConnectionManager.handle_write', wrapper_GearmanConnectionManager_handle_function) wrap_function_wrapper(module, 'GearmanConnectionManager.handle_error', wrapper_GearmanConnectionManager_handle_function) wrap_function_wrapper( module, 'GearmanConnectionManager.poll_connections_until_stopped', wrapper_GearmanConnectionManager_poll_connections_until_stopped)
def instrument_tornado_template(module): wrap_function_wrapper(module, 'Template.generate', template_generate_wrapper) wrap_function_wrapper(module, 'Template._generate_python', template_generate_python_wrapper) wrap_function_wrapper(module, '_NamedBlock.generate', block_generate_wrapper)
def patch_motor(module): wrap_function_wrapper(module, 'MotorClientBase.__getattr__', _bw_wrapper_Motor_getattr_) wrap_function_wrapper(module, 'MotorDatabase.__getattr__', _bw_wrapper_Motor_getattr_) wrap_function_wrapper(module, 'MotorCollection.__getattr__', _bw_wrapper_Motor_getattr_)
def instrument_tornado_wsgi(module): wrap_function_wrapper(module, 'WSGIContainer.__init__', _bw_wrapper_WSGIContainer___init___) wrap_function_wrapper(module, 'WSGIContainer.__call__', _bw_wrapper_WSGIContainer___call___) import tornado if hasattr(tornado, 'version_info'): version = '.'.join(map(str, tornado.version_info)) else: version = None framework = ('Tornado/WSGI', version) wrap_wsgi_application(module, 'WSGIApplication.__call__', framework=framework) # For tornado 4.0+ if hasattr(module, 'WSGIAdapter'): wrap_wsgi_application(module, 'WSGIAdapter.__call__', framework=('Tornado/WSGI', version))
def _bw_wrapper_RequestHandler___init___(wrapped, instance, args, kwargs): # In this case we are actually wrapping the instance method on an # actual instance of a handler class rather than the class itself. # This is so we can wrap any derived version of this method when # it has been overridden in a handler class. wrap_function_wrapper(instance, 'on_connection_close', _bw_wrapper_RequestHandler_on_connection_close) wrap_function_trace(instance, 'prepare') if hasattr(instance, 'on_finish'): wrap_function_trace(instance, 'on_finish') handler = instance for name in handler.SUPPORTED_METHODS: name = name.lower() if hasattr(handler, name): wrap_function_trace(instance, name) return wrapped(*args, **kwargs)
def instrument_cyclone_httpserver(module): if hasattr(module, 'HTTPConnection'): wrap_function_wrapper(module, 'HTTPConnection._on_headers', _bw_wrapper_HTTPConnection__on_headers_) wrap_function_wrapper(module, 'HTTPConnection._on_request_body', _bw_wrapper_HTTPConnection__on_request_body_) wrap_function_wrapper(module, 'HTTPConnection._finish_request', _bw_wrapper_HTTPConnection__finish_request) if hasattr(module.HTTPConnection, '_parse_mime_body'): wrap_function_trace(module, 'HTTPConnection._parse_mime_body')
def instrument_tornado_httpserver(module): if hasattr(module, 'HTTPConnection'): # The HTTPConnection class only existed prior to Tornado 4.0. wrap_function_wrapper(module, 'HTTPConnection._on_headers', _bw_wrapper_HTTPConnection__on_headers_) wrap_function_wrapper(module, 'HTTPConnection._on_request_body', _bw_wrapper_HTTPConnection__on_request_body_) wrap_function_wrapper(module, 'HTTPConnection._finish_request', _bw_wrapper_HTTPConnection__finish_request) if hasattr(module.HTTPConnection, '_parse_mime_body'): wrap_function_trace(module, 'HTTPConnection._parse_mime_body')
def instrument_django_template_base(module): global module_django_template_base module_django_template_base = module settings = global_settings() if 'django.instrumentation.inclusion-tags.r1' in settings.feature_flag: wrap_function_wrapper(module, 'generic_tag_compiler', _bw_wrapper_django_template_base_generic_tag_compiler_) wrap_function_wrapper(module, 'Library.tag', _bw_wrapper_django_template_base_Library_tag_) wrap_function_wrapper(module, 'Library.inclusion_tag', _bw_wrapper_django_template_base_Library_inclusion_tag_)
def instrument_django_template_base(module): global module_django_template_base module_django_template_base = module settings = global_settings() if 'django.instrumentation.inclusion-tags.r1' in settings.feature_flag: wrap_function_wrapper( module, 'generic_tag_compiler', _bw_wrapper_django_template_base_generic_tag_compiler_) wrap_function_wrapper(module, 'Library.tag', _bw_wrapper_django_template_base_Library_tag_) wrap_function_wrapper( module, 'Library.inclusion_tag', _bw_wrapper_django_template_base_Library_inclusion_tag_)
def instrument_tornado_ioloop(module): wrap_function_trace(module, 'IOLoop.add_handler') wrap_function_trace(module, 'IOLoop.add_timeout') wrap_function_wrapper(module, 'IOLoop.add_callback', _bw_wrapper_IOLoop_add_callback_) if hasattr(module.IOLoop, 'add_future'): wrap_function_wrapper(module, 'IOLoop.add_future', _bw_wrapper_IOLoop_add_future_) if hasattr(module, 'PollIOLoop'): wrap_function_trace(module, 'PollIOLoop.add_handler') # For Tornado 4.0+, PollIOLoop.add_timeout has been removed. if hasattr(module.PollIOLoop, 'add_timeout'): wrap_function_trace(module, 'PollIOLoop.add_timeout') wrap_function_wrapper(module, 'PollIOLoop.add_callback', _bw_wrapper_IOLoop_add_callback_) wrap_function_trace(module, 'PollIOLoop.add_callback_from_signal')
def instrument(module): if hasattr(module, 'urlretrieve'): _bw_wrapper_urlretrieve_ = _bw_wrapper_factory( bind_params_urlretrieve, 'urllib') wrap_function_wrapper(module, 'urlretrieve', _bw_wrapper_urlretrieve_) if hasattr(module, 'URLopener'): _bw_wrapper_url_opener_open_ = _bw_wrapper_factory( bind_params_open, 'urllib') wrap_function_wrapper(module, 'URLopener.open', _bw_wrapper_url_opener_open_) if hasattr(module, 'OpenerDirector'): _bw_wrapper_opener_director_open_ = _bw_wrapper_factory( bind_params_open, 'urllib2') wrap_function_wrapper(module, 'OpenerDirector.open', _bw_wrapper_opener_director_open_)
def instrument(module): if hasattr(module, 'urlretrieve'): _bw_wrapper_urlretrieve_ = _bw_wrapper_factory(bind_params_urlretrieve, 'urllib') wrap_function_wrapper(module, 'urlretrieve', _bw_wrapper_urlretrieve_) if hasattr(module, 'URLopener'): _bw_wrapper_url_opener_open_ = _bw_wrapper_factory( bind_params_open, 'urllib') wrap_function_wrapper(module, 'URLopener.open', _bw_wrapper_url_opener_open_) if hasattr(module, 'OpenerDirector'): _bw_wrapper_opener_director_open_ = _bw_wrapper_factory( bind_params_open, 'urllib2') wrap_function_wrapper(module, 'OpenerDirector.open', _bw_wrapper_opener_director_open_)
def instrument_umemcache(module): wrap_function_wrapper(module, 'Client', _bw_umemcache_Client_wrapper_)
def instrument(module): if hasattr(module, 'OpenerDirector'): wrap_function_wrapper(module, 'OpenerDirector.open', _bw_wrapper_opener_director_open_)
def instrument_gearman_worker(module): wrap_function_wrapper(module, 'GearmanWorker.on_job_execute', wrapper_GearmanWorker_on_job_execute) wrap_function_wrapper(module, 'GearmanWorker.register_task', wrapper_GearmanWorker_register_task)
def instrument_django_core_management_base(module): wrap_function_wrapper(module, 'BaseCommand.__init__', _bw_wrapper_BaseCommand___init___) wrap_function_wrapper(module, 'BaseCommand.run_from_argv', _bw_wrapper_BaseCommand_run_from_argv_)
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)
def instrument_flask_blueprints(module): wrap_function_wrapper(module, 'Blueprint.endpoint', _bw_wrapper_Blueprint_endpoint_) if hasattr(module.Blueprint, 'before_request'): wrap_function_wrapper(module, 'Blueprint.before_request', _bw_wrapper_Blueprint_before_request_) if hasattr(module.Blueprint, 'before_app_request'): wrap_function_wrapper(module, 'Blueprint.before_app_request', _bw_wrapper_Blueprint_before_app_request_) if hasattr(module.Blueprint, 'before_app_first_request'): wrap_function_wrapper(module, 'Blueprint.before_app_first_request', _bw_wrapper_Blueprint_before_app_first_request_) if hasattr(module.Blueprint, 'after_request'): wrap_function_wrapper(module, 'Blueprint.after_request', _bw_wrapper_Blueprint_after_request_) if hasattr(module.Blueprint, 'after_app_request'): wrap_function_wrapper(module, 'Blueprint.after_app_request', _bw_wrapper_Blueprint_after_app_request_) if hasattr(module.Blueprint, 'teardown_request'): wrap_function_wrapper(module, 'Blueprint.teardown_request', _bw_wrapper_Blueprint_teardown_request_) if hasattr(module.Blueprint, 'teardown_app_request'): wrap_function_wrapper(module, 'Blueprint.teardown_app_request', _bw_wrapper_Blueprint_teardown_app_request_)
def instrument_cyclone_web(module): wrap_function_wrapper(module, 'Application.__call__', _bw_wrapper_Application___call___) wrap_function_wrapper( module, 'RequestHandler._handle_request_exception', _bw_wrapper_RequestHandler__handle_request_exception_) wrap_function_wrapper(module, 'RequestHandler._execute', _bw_wrapper_RequestHandler__execute_) if hasattr(module.RequestHandler, '_execute_handler'): wrap_function_wrapper(module, 'RequestHandler._execute_handler', _bw_wrapper_RequestHandler__execute_handler_) wrap_function_wrapper(module, 'RequestHandler.finish', _bw_wrapper_RequestHandler_finish_) if hasattr(module.RequestHandler, '_generate_headers'): wrap_function_wrapper(module, 'RequestHandler._generate_headers', _bw_wrapper_RequestHandler__generate_headers_) wrap_function_wrapper(module, 'RequestHandler.__init__', _bw_wrapper_RequestHandler___init___)
def instrument_cornice_service(module): global module_cornice_service module_cornice_service = module wrap_function_wrapper(module, 'decorate_view', wrapper_decorate_view)
def instrument_flask_app(module): wrap_wsgi_application(module, 'Flask.wsgi_app', framework=framework_details()) wrap_function_wrapper(module, 'Flask.add_url_rule', _bw_wrapper_Flask_add_url_rule_input_) if hasattr(module.Flask, 'endpoint'): wrap_function_wrapper(module, 'Flask.endpoint', _bw_wrapper_Flask_endpoint_) wrap_function_wrapper(module, 'Flask.handle_http_exception', _bw_wrapper_Flask_handle_http_exception_) # Use the same wrapper for initial user exception processing and # fallback for unhandled exceptions. if hasattr(module.Flask, 'handle_user_exception'): wrap_function_wrapper(module, 'Flask.handle_user_exception', _bw_wrapper_Flask_handle_exception_) wrap_function_wrapper(module, 'Flask.handle_exception', _bw_wrapper_Flask_handle_exception_) # The _register_error_handler() method was only introduced in # Flask version 0.7.0. if hasattr(module.Flask, '_register_error_handler'): wrap_function_wrapper(module, 'Flask._register_error_handler', _bw_wrapper_Flask__register_error_handler_) # Different before/after methods were added in different versions. # Check for the presence of everything before patching. if hasattr(module.Flask, 'try_trigger_before_first_request_functions'): wrap_function_wrapper( module, 'Flask.try_trigger_before_first_request_functions', _bw_wrapper_Flask_try_trigger_before_first_request_functions_) wrap_function_wrapper(module, 'Flask.before_first_request', _bw_wrapper_Flask_before_first_request_) if hasattr(module.Flask, 'preprocess_request'): wrap_function_trace(module, 'Flask.preprocess_request') wrap_function_wrapper(module, 'Flask.before_request', _bw_wrapper_Flask_before_request_) if hasattr(module.Flask, 'process_response'): wrap_function_trace(module, 'Flask.process_response') wrap_function_wrapper(module, 'Flask.after_request', _bw_wrapper_Flask_after_request_) if hasattr(module.Flask, 'do_teardown_request'): wrap_function_trace(module, 'Flask.do_teardown_request') wrap_function_wrapper(module, 'Flask.teardown_request', _bw_wrapper_Flask_teardown_request_) if hasattr(module.Flask, 'do_teardown_appcontext'): wrap_function_trace(module, 'Flask.do_teardown_appcontext') wrap_function_wrapper(module, 'Flask.teardown_appcontext', _bw_wrapper_Flask_teardown_appcontext_)
def instrument_psycopg2__range(module): if hasattr(module, 'register_type'): if not isinstance(module.register_type, ObjectProxy): wrap_function_wrapper(module, 'register_type', wrapper_psycopg2_register_type)
def instrument_rest_framework_views(module): wrap_function_wrapper(module, 'APIView.dispatch', _bw_wrapper_APIView_dispatch_)
def instrument_twisted_web_wsgi(module): wrap_function_wrapper(module, 'WSGIResource.__init__', _bw_wrapper_WSGIResource___init___)
def instrument_tornado_http1connection(module): if hasattr(module, 'HTTP1Connection'): # The HTTP1Connection class only existed in Tornado 4.0+. wrap_function_wrapper(module, 'HTTP1Connection._finish_request', _bw_wrapper_HTTP1Connection__finish_request)
def instrument_cyclone_web(module): wrap_function_wrapper(module, 'Application.__call__', _bw_wrapper_Application___call___) wrap_function_wrapper(module, 'RequestHandler._handle_request_exception', _bw_wrapper_RequestHandler__handle_request_exception_) wrap_function_wrapper(module, 'RequestHandler._execute', _bw_wrapper_RequestHandler__execute_) if hasattr(module.RequestHandler, '_execute_handler'): wrap_function_wrapper(module, 'RequestHandler._execute_handler', _bw_wrapper_RequestHandler__execute_handler_) wrap_function_wrapper(module, 'RequestHandler.finish', _bw_wrapper_RequestHandler_finish_) if hasattr(module.RequestHandler, '_generate_headers'): wrap_function_wrapper(module, 'RequestHandler._generate_headers', _bw_wrapper_RequestHandler__generate_headers_) wrap_function_wrapper(module, 'RequestHandler.__init__', _bw_wrapper_RequestHandler___init___)
def instrument_tornado_web(module): wrap_function_wrapper(module, 'Application.__call__', _bw_wrapper_Application___call___) wrap_function_wrapper(module, 'RequestHandler._handle_request_exception', _bw_wrapper_RequestHandler__handle_request_exception_) # Tornado 3.1 and later supports the prepare() method being a # coroutine and so execution of the get handler is actually deferred # to _execute_method(). wrap_function_wrapper(module, 'RequestHandler._execute', _bw_wrapper_RequestHandler__execute_) if hasattr(module.RequestHandler, '_execute_method'): wrap_function_wrapper(module, 'RequestHandler._execute_method', _bw_wrapper_RequestHandler__execute_method_) # This mucks up Tornado's calculation of where template files live # as Tornado does walking of the stack frames to work it out and the # wrapper makes it stop before getting to the users code. Thus is # disabled for now. # wrap_function_wrapper(module, 'RequestHandler.render', # _bw_wrapper_RequestHandler_render_) # wrap_function_wrapper(module, 'RequestHandler.render_string', # _bw_wrapper_RequestHandler_render_) wrap_function_wrapper(module, 'RequestHandler.finish', _bw_wrapper_RequestHandler_finish_) if hasattr(module.RequestHandler, '_generate_headers'): # The _generate_headers() method only existed prior to Tornado 4.0. wrap_function_wrapper(module, 'RequestHandler._generate_headers', _bw_wrapper_RequestHandler__generate_headers_) wrap_function_wrapper(module, 'RequestHandler.__init__', _bw_wrapper_RequestHandler___init___) if hasattr(module, '_RequestDispatcher'): wrap_function_wrapper(module, '_RequestDispatcher.execute', _bw_wrapper__RequestDispatcher_execute) wrap_function_wrapper(module, '_RequestDispatcher.set_request', _bw_wrapper__RequestDispatcher_set_request)
def instrument_urllib3_connectionpool(module): wrap_function_wrapper(module, 'HTTPConnectionPool._make_request', _bw_wrapper_make_request_)
def instrument_flask_compress(module): wrap_function_wrapper(module, 'Compress.after_request', _bw_wrapper_Compress_after_request)
def instrument_tornado_stack_context(module): global module_stack_context module_stack_context = module wrap_function_wrapper(module, 'wrap', _bw_stack_context_wrap_wrapper_)
def instrument_flask_app(module): wrap_wsgi_application(module, 'Flask.wsgi_app', framework=framework_details()) wrap_function_wrapper(module, 'Flask.add_url_rule', _bw_wrapper_Flask_add_url_rule_input_) if hasattr(module.Flask, 'endpoint'): wrap_function_wrapper(module, 'Flask.endpoint', _bw_wrapper_Flask_endpoint_) wrap_function_wrapper(module, 'Flask.handle_http_exception', _bw_wrapper_Flask_handle_http_exception_) # Use the same wrapper for initial user exception processing and # fallback for unhandled exceptions. if hasattr(module.Flask, 'handle_user_exception'): wrap_function_wrapper(module, 'Flask.handle_user_exception', _bw_wrapper_Flask_handle_exception_) wrap_function_wrapper(module, 'Flask.handle_exception', _bw_wrapper_Flask_handle_exception_) # The _register_error_handler() method was only introduced in # Flask version 0.7.0. if hasattr(module.Flask, '_register_error_handler'): wrap_function_wrapper(module, 'Flask._register_error_handler', _bw_wrapper_Flask__register_error_handler_) # Different before/after methods were added in different versions. # Check for the presence of everything before patching. if hasattr(module.Flask, 'try_trigger_before_first_request_functions'): wrap_function_wrapper(module, 'Flask.try_trigger_before_first_request_functions', _bw_wrapper_Flask_try_trigger_before_first_request_functions_) wrap_function_wrapper(module, 'Flask.before_first_request', _bw_wrapper_Flask_before_first_request_) if hasattr(module.Flask, 'preprocess_request'): wrap_function_trace(module, 'Flask.preprocess_request') wrap_function_wrapper(module, 'Flask.before_request', _bw_wrapper_Flask_before_request_) if hasattr(module.Flask, 'process_response'): wrap_function_trace(module, 'Flask.process_response') wrap_function_wrapper(module, 'Flask.after_request', _bw_wrapper_Flask_after_request_) if hasattr(module.Flask, 'do_teardown_request'): wrap_function_trace(module, 'Flask.do_teardown_request') wrap_function_wrapper(module, 'Flask.teardown_request', _bw_wrapper_Flask_teardown_request_) if hasattr(module.Flask, 'do_teardown_appcontext'): wrap_function_trace(module, 'Flask.do_teardown_appcontext') wrap_function_wrapper(module, 'Flask.teardown_appcontext', _bw_wrapper_Flask_teardown_appcontext_)
def instrument_redis_connection(module): wrap_function_wrapper(module, 'Connection.send_command', _bw_Connection_send_command_wrapper_)