• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python agent.wrap_function_wrapper函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中newrelic.agent.wrap_function_wrapper函数的典型用法代码示例。如果您正苦于以下问题:Python wrap_function_wrapper函数的具体用法?Python wrap_function_wrapper怎么用?Python wrap_function_wrapper使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了wrap_function_wrapper函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: wrap_elasticsearch_client_method

def wrap_elasticsearch_client_method(owner, name, arg_extractor, prefix=None):
    def _nr_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, _nr_wrapper_Elasticsearch_method_)
开发者ID:Dragoon013,项目名称:newrelic-python-kata,代码行数:29,代码来源:datastore_elasticsearch.py


示例2: _wrap_Redis_method_wrapper_

def _wrap_Redis_method_wrapper_(module, instance_class_name, operation):

    def _nr_wrapper_Redis_method_(wrapped, instance, args, kwargs):
        transaction = current_transaction()

        if transaction is None:
            return wrapped(*args, **kwargs)

        dt = DatastoreTrace(
                transaction,
                product='Redis',
                target=None,
                operation=operation
        )

        transaction._nr_datastore_instance_info = (None, None, None)

        with dt:
            result = wrapped(*args, **kwargs)

            host, port_path_or_id, db = transaction._nr_datastore_instance_info
            dt.host = host
            dt.port_path_or_id = port_path_or_id
            dt.database_name = db

            return result

    name = '%s.%s' % (instance_class_name, operation)
    wrap_function_wrapper(module, name, _nr_wrapper_Redis_method_)
开发者ID:edmorley,项目名称:newrelic-python-agent,代码行数:29,代码来源:datastore_redis.py


示例3: instrument_flask_app

def instrument_flask_app(module):
    wrap_wsgi_application(module, 'Flask.wsgi_app',
            framework=framework_details())

    wrap_function_wrapper(module, 'Flask.add_url_rule',
            wrapper_Flask_add_url_rule_input)

    wrap_function_wrapper(module, 'Flask.handle_http_exception',
            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',
                wrapper_Flask_handle_exception)

    wrap_function_wrapper(module, 'Flask.handle_exception',
            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',
                wrapper_Flask__register_error_handler)
开发者ID:Arable,项目名称:evepod,代码行数:26,代码来源:framework_flask.py


示例4: instrument_tornado_wsgi

def instrument_tornado_wsgi(module):
    wrap_function_wrapper(module, 'WSGIContainer.__init__',
            _nr_wrapper_WSGIContainer___init___)
    wrap_function_wrapper(module, 'WSGIContainer.__call__',
            _nr_wrapper_WSGIContainer___call___)

    wrap_wsgi_application(module, 'WSGIApplication.__call__')
开发者ID:TheTincho,项目名称:python-newrelic,代码行数:7,代码来源:wsgi.py


示例5: instrument_tornado_iostream

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)
开发者ID:Dragoon013,项目名称:newrelic-python-kata,代码行数:9,代码来源:iostream.py


示例6: instrument_urllib3_connection

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'))
开发者ID:Dragoon013,项目名称:newrelic-python-kata,代码行数:11,代码来源:external_urllib3.py


示例7: instrument_memcache

def instrument_memcache(module):
    wrap_function_wrapper(module.Client, '_get_server', _nr_get_server_wrapper)

    for name in _memcache_client_methods:
        if hasattr(module.Client, name):
            wrap_memcache_single(module, name,
                    product='Memcached', target=None, operation=name)

    for name in _memcache_multi_methods:
        if hasattr(module.Client, name):
            wrap_datastore_trace(module.Client, name,
                    product='Memcached', target=None, operation=name)
开发者ID:edmorley,项目名称:newrelic-python-agent,代码行数:12,代码来源:datastore_memcache.py


示例8: instrument_gearman_client

def instrument_gearman_client(module):
    wrap_function_trace(module, 'GearmanClient.submit_job')
    wrap_function_trace(module, 'GearmanClient.submit_multiple_jobs')
    wrap_function_trace(module, 'GearmanClient.submit_multiple_requests')
    wrap_function_trace(module, 'GearmanClient.wait_until_jobs_accepted')
    wrap_function_trace(module, 'GearmanClient.wait_until_jobs_completed')
    wrap_function_trace(module, 'GearmanClient.get_job_status')
    wrap_function_trace(module, 'GearmanClient.get_job_statuses')
    wrap_function_trace(module, 'GearmanClient.wait_until_job_statuses_received')

    wrap_function_wrapper(module, 'GearmanClient.poll_connections_until_stopped',
            wrapper_GearmanClient_poll_connections_until_stopped)
开发者ID:Arable,项目名称:evepod,代码行数:12,代码来源:application_gearman.py


示例9: instrument_dyndns53

def instrument_dyndns53(module):
    wrap_function_trace(module, 'initialise_database')
    wrap_function_trace(module, 'download_database')
    wrap_function_trace(module, 'upload_database')

    wrap_function_trace(module, 'register_ip')

    wrap_function_trace(module, 'BasicAuthDatabase.check_credentials')

    wrap_function_wrapper(module, 'register_ip', wrapper_register_ip)

    for name, callback in list(module._commands.items()):
        module._commands[name] = BackgroundTaskWrapper(callback)
开发者ID:nathankot,项目名称:dyndns53,代码行数:13,代码来源:instrument.py


示例10: instrument

def instrument(module):

    wrap_function_wrapper(module, 'HTTPConnectionWithTimeout.connect',
            _nr_wrapper_httplib2_connect_wrapper('http'))

    wrap_function_wrapper(module, 'HTTPSConnectionWithTimeout.connect',
            _nr_wrapper_httplib2_connect_wrapper('https'))

    def url_request(connection, uri, *args, **kwargs):
        return uri

    newrelic.api.external_trace.wrap_external_trace(
           module, 'Http.request', 'httplib2', url_request)
开发者ID:bobbyrward,项目名称:newrelic,代码行数:13,代码来源:external_httplib2.py


示例11: instrument_dyndns53

def instrument_dyndns53(module):
    wrap_function_trace(module, 'initialise_database')
    wrap_function_trace(module, 'download_database')
    wrap_function_trace(module, 'upload_database')

    wrap_function_trace(module, 'register_ip')

    wrap_function_trace(module, 'BasicAuthDatabase.check_credentials')

    wrap_background_task(module, 'upload_database_command')
    wrap_background_task(module, 'download_database_command')

    wrap_function_wrapper(module, 'register_ip', wrapper_register_ip)
开发者ID:simbha,项目名称:dyndns53,代码行数:13,代码来源:instrument.py


示例12: instrument_tornado_gen

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', _nr_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', _nr_wrapper_gen_coroutine_)

    if hasattr(module, 'Runner'):
        wrap_function_wrapper(module, 'Runner.__init__',
                _nr_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',
                    _nr_wrapper_Task_start_)
开发者ID:TheTincho,项目名称:python-newrelic,代码行数:29,代码来源:gen.py


示例13: instrument_tornado_wsgi

def instrument_tornado_wsgi(module):
    wrap_function_wrapper(module, 'WSGIContainer.__init__',
            _nr_wrapper_WSGIContainer___init___)
    wrap_function_wrapper(module, 'WSGIContainer.__call__',
            _nr_wrapper_WSGIContainer___call___)

    import tornado

    if hasattr(tornado, 'version_info'):
        version = '.'.join(map(str, tornado.version_info))
    else:
        version = None

    wrap_wsgi_application(module, 'WSGIApplication.__call__',
            framework=('Tornado/WSGI', version))
开发者ID:Dragoon013,项目名称:newrelic-python-kata,代码行数:15,代码来源:wsgi.py


示例14: instrument_pybald_app

def instrument_pybald_app(app, name=None):
    '''
    Monkeypatch the Pybald Router and instrument the WSGI stack with
    FunctionTrace wrappers.

    This allows the breakdown of all of the components in the Pybald stack and
    also sets the transaction names to the controller/action pairs for
    user code.

    :param app: A WSGI application to apply newrelic instrumentation to
    :param name: The (optional) name of the application
    '''
    import pybald.core.router
    wrap_function_wrapper(pybald.core.router, 'Router.get_handler',
                          wrapper_Pybald_Router_get_handler)
    return instrument_pybald(app, name=name)
开发者ID:killthrush,项目名称:pybald,代码行数:16,代码来源:pybald_newrelic.py


示例15: patch_motor

def patch_motor(module):
    wrap_function_wrapper(module, 'MotorClient.__getattr__',
            _nr_wrapper_Motor_getattr_)
    wrap_function_wrapper(module, 'MotorReplicaSetClient.__getattr__',
            _nr_wrapper_Motor_getattr_)
    wrap_function_wrapper(module, 'MotorDatabase.__getattr__',
            _nr_wrapper_Motor_getattr_)
    wrap_function_wrapper(module, 'MotorCollection.__getattr__',
            _nr_wrapper_Motor_getattr_)
开发者ID:Read-The-Fucking-Source-Code,项目名称:new-relic-python,代码行数:9,代码来源:datastore_motor.py


示例16: instrument_bottle

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')
开发者ID:Dragoon013,项目名称:newrelic-python-kata,代码行数:44,代码来源:framework_bottle.py


示例17: instrument_gearman_connection_manager

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)
开发者ID:Dragoon013,项目名称:newrelic-python-kata,代码行数:11,代码来源:application_gearman.py


示例18: _nr_wrapper_RequestHandler___init___

def _nr_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',
            _nr_wrapper_RequestHandler_on_connection_close)

    wrap_function_trace(instance, 'prepare')
    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)
开发者ID:TheTincho,项目名称:python-newrelic,代码行数:20,代码来源:web.py


示例19: instrument_tornado_web

def instrument_tornado_web(module):
    wrap_function_wrapper(module, 'RequestHandler._execute',
            _nr_wrapper_RequestHandler__execute_)
    wrap_function_wrapper(module, 'RequestHandler._handle_request_exception',
            _nr_wrapper_RequestHandler__handle_request_exception_)
    wrap_function_wrapper(module, 'RequestHandler.__init__',
            _nr_wrapper_RequestHandler__init__)
开发者ID:bobbyrward,项目名称:newrelic,代码行数:7,代码来源:web.py


示例20: instrument_tornado_template

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)
开发者ID:Dragoon013,项目名称:newrelic-python-kata,代码行数:7,代码来源:template.py



注:本文中的newrelic.agent.wrap_function_wrapper函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python object_wrapper.callable_name函数代码示例发布时间:2022-05-27
下一篇:
Python agent.current_transaction函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap