def wrap_create_task(wrapped, instance, args, kwargs):
    loop = _bind_loop(*args, **kwargs)

    if loop and not hasattr(loop.create_task, '__wrapped__'):
        wrap_out_function(loop, 'create_task', propagate_task_context)

    return wrapped(*args, **kwargs)
def instrument_pyramid_config_views(module):
    # Location of the ViewDeriver class changed from pyramid.config to
    # pyramid.config.views so check if present before trying to update.

    if hasattr(module, 'ViewDeriver'):
        wrap_out_function(module, 'ViewDeriver.__call__', wrap_view_handler)
    elif hasattr(module, 'Configurator'):
        wrap_out_function(module, 'Configurator._derive_view',
                          wrap_view_handler)

    if hasattr(module, 'DefaultViewMapper'):
        module.DefaultViewMapper.map_class_requestonly = FunctionWrapper(
            module.DefaultViewMapper.map_class_requestonly,
            default_view_mapper_wrapper)
        module.DefaultViewMapper.map_class_native = FunctionWrapper(
            module.DefaultViewMapper.map_class_native,
            default_view_mapper_wrapper)
Beispiel #3
0
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_gunicorn_app_base(module):
    wrap_out_function(module, 'Application.wsgi',
                      _nr_wrapper_Application_wsgi_)
Beispiel #5
0
def instrument_asyncio_base_events(module):
    wrap_out_function(module, 'BaseEventLoop.create_task',
                      propagate_task_context)