当前位置: 首页>>代码示例>>Python>>正文


Python agent.wrap_function_wrapper函数代码示例

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


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


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