コード例 #1
0
def instrument_cx_oracle(module):
    register_database_client(module,
                             database_product='Oracle',
                             quoting_style='single+oracle')

    wrap_object(module, 'connect', ConnectionFactory, (module, ))
    wrap_object(module, 'SessionPool', CreateSessionPoolProxy, (module, ))
コード例 #2
0
def instrument_sqlite3_dbapi2(module):
    register_database_client(module,
                             'SQLite',
                             quoting_style='single+double',
                             instance_info=instance_info)

    wrap_object(module, 'connect', ConnectionFactory, (module, ))
コード例 #3
0
def wrap_datastore_trace(module, object_path, product, target, operation):
    """Method applies custom timing to datastore query.

    :param module: Module containing the method to be instrumented.
    :type module: object
    :param object_path: The path to the location of the function.
    :type object_path: str
    :param product: The name of the vendor.
    :type product: str
    :param target: The name of the collection or table. If the name is unknown,
                   'other' should be used.
    :type target: str
    :param operation: The name of the datastore operation. This can be the
                      primitive operation type accepted by the datastore itself
                      or the name of any API function/method in the client
                      library.
    :type operation: str

    This is typically used to time database query method calls such as Redis
    GET.

    Usage::

        >>> import newrelic.agent
        >>> import time
        >>> newrelic.agent.wrap_datastore_trace(time, 'sleep', 'time', None,
        ...        'sleep')

    """
    wrap_object(module, object_path, DatastoreTraceWrapper,
                (product, target, operation))
コード例 #4
0
def instrument_psycopg2cffi(module):
    register_database_client(module, database_product='Postgres',
            quoting_style='single', explain_query='explain',
            explain_stmts=('select', 'insert', 'update', 'delete'),
            instance_info=instance_info)

    wrap_object(module, 'connect', ConnectionFactory, (module,))
コード例 #5
0
def wrap_function_profile(module,
                          object_path,
                          filename,
                          delay=1.0,
                          checkpoint=30):
    wrap_object(module, object_path, FunctionProfileWrapper,
                (filename, delay, checkpoint))
コード例 #6
0
def wrap_background_task(module,
                         object_path,
                         application=None,
                         name=None,
                         group=None):
    wrap_object(module, object_path, BackgroundTaskWrapper,
                (application, name, group))
コード例 #7
0
def instrument_pymssql(module):
    # XXX Don't believe MSSQL provides a simple means of doing an
    # explain plan using one SQL statement prefix, eg., 'EXPLAIN'.

    register_database_client(module, database_product='MSSQL',
            quoting_style='single')

    wrap_object(module, 'connect', ConnectionFactory, (module,))
コード例 #8
0
def wrap_wsgi_application(module,
                          object_path,
                          application=None,
                          name=None,
                          group=None,
                          framework=None):
    wrap_object(module, object_path, WSGIApplicationWrapper,
                (application, name, group, framework))
コード例 #9
0
ファイル: message_transaction.py プロジェクト: lxp20201/lxp
def wrap_message_transaction(module, object_path, library, destination_type,
        destination_name, application=None, routing_key=None,
        exchange_type=None, headers=None, queue_name=None, reply_to=None,
        correlation_id=None):
    wrap_object(module, object_path, MessageTransactionWrapper,
            (library, destination_type, destination_name, application,
            routing_key, exchange_type, headers, queue_name, reply_to,
            correlation_id))
コード例 #10
0
def wrap_message_trace(module,
                       object_path,
                       library,
                       operation,
                       destination_type,
                       destination_name,
                       params={}):
    wrap_object(
        module, object_path, MessageTraceWrapper,
        (library, operation, destination_type, destination_name, params))
コード例 #11
0
def instrument_postgresql_interface_proboscis_dbapi2(module):
    register_database_client(module,
                             database_product='Postgres',
                             quoting_style='single+dollar',
                             explain_query='explain',
                             explain_stmts=('select', 'insert', 'update',
                                            'delete'),
                             instance_info=instance_info)

    from newrelic.hooks.database_dbapi2 import ConnectionFactory

    wrap_object(module, 'connect', ConnectionFactory, (module, ))
コード例 #12
0
ファイル: database_sqlite.py プロジェクト: jimmoffet/VoteBot
def instrument_sqlite3(module):
    # This case is to handle where the sqlite3 module was already
    # imported prior to agent initialization. In this situation, a
    # reference to the connect() method would already have been created
    # which referred to the uninstrumented version of the function
    # originally imported by sqlite3.dbapi2 before instrumentation could
    # be applied.

    if not isinstance(module.connect, ConnectionFactory):
        register_database_client(module, 'SQLite', instance_info=instance_info)

        wrap_object(module, 'connect', ConnectionFactory, (module, ))
コード例 #13
0
def instrument_pika_adapters(module):
    _wrap_Channel_consume_callback(module.blocking_connection,
                                   'BlockingChannel.basic_consume',
                                   _bind_params_BlockingChannel_basic_consume,
                                   'consumer_callback')
    wrap_function_wrapper(module.blocking_connection,
                          'BlockingChannel.__init__',
                          _nr_wrap_BlockingChannel___init__)
    wrap_object(module.blocking_connection, 'BlockingChannel.consume',
                _ConsumeGeneratorWrapper)

    if hasattr(module, 'tornado_connection'):
        wrap_function_wrapper(module.tornado_connection,
                              'TornadoConnection.channel',
                              _disable_channel_transactions)
コード例 #14
0
def instrument_oursql(module):
    register_database_client(module, database_product='MySQL',
            quoting_style='single+double', explain_query='explain',
            explain_stmts=('select',), instance_info=instance_info)

    wrap_object(module, 'connect', ConnectionFactory, (module,))

    # The connect() function is actually aliased with Connect() and
    # Connection, the later actually being the Connection type object.
    # Instrument Connect(), but don't instrument Connection in case that
    # interferes with direct type usage. If people are using the
    # Connection object directly, they should really be using connect().

    if hasattr(module, 'Connect'):
        wrap_object(module, 'Connect', ConnectionFactory, (module,))
コード例 #15
0
def wrap_transaction_name(module,
                          object_path,
                          name=None,
                          group=None,
                          priority=None):
    return wrap_object(module, object_path, TransactionNameWrapper,
                       (name, group, priority))
コード例 #16
0
def wrap_error_trace(module,
                     object_path,
                     ignore_errors=[],
                     ignore=None,
                     expected=None,
                     status_code=None):
    wrap_object(
        module,
        object_path,
        ErrorTraceWrapper,
        (
            ignore_errors,
            ignore,
            expected,
            status_code,
        ),
    )
コード例 #17
0
ファイル: generator_trace.py プロジェクト: jimmoffet/VoteBot
def wrap_generator_trace(module,
                         object_path,
                         name=None,
                         group=None,
                         label=None,
                         params=None):
    return wrap_object(module, object_path, GeneratorTraceWrapper,
                       (name, group, label, params))
コード例 #18
0
def wrap_profile_trace(module,
                       object_path,
                       name=None,
                       group=None,
                       label=None,
                       params=None,
                       depth=3):
    return wrap_object(module, object_path, ProfileTraceWrapper,
                       (name, group, label, params, depth))
コード例 #19
0
def wrap_function_trace(module,
                        object_path,
                        name=None,
                        group=None,
                        label=None,
                        params=None,
                        terminal=False,
                        rollup=None):
    return wrap_object(module, object_path, FunctionTraceWrapper,
                       (name, group, label, params, terminal, rollup))
コード例 #20
0
def instrument_pika_adapters(module):
    import pika
    version = tuple(int(num) for num in pika.__version__.split('.', 1)[0])

    if version[0] < 1:
        wrap_consume = _wrap_basic_consume_BlockingChannel_old
    else:
        wrap_consume = _wrap_basic_consume_Channel

    _wrap_Channel_consume_callback(
            module.blocking_connection,
            'BlockingChannel.basic_consume',
            wrap_consume)
    wrap_function_wrapper(module.blocking_connection,
            'BlockingChannel.__init__', _nr_wrap_BlockingChannel___init__)
    wrap_object(module.blocking_connection, 'BlockingChannel.consume',
            _ConsumeGeneratorWrapper)

    if hasattr(module, 'tornado_connection'):
        wrap_function_wrapper(module.tornado_connection,
                'TornadoConnection.channel', _disable_channel_transactions)
コード例 #21
0
def wrap_web_transaction(module,
                         object_path,
                         application=None,
                         name=None,
                         group=None,
                         scheme=None,
                         host=None,
                         port=None,
                         request_method=None,
                         request_path=None,
                         query_string=None,
                         headers=None):

    return wrap_object(module, object_path, WebTransactionWrapper,
                       (application, name, group, scheme, host, port,
                        request_method, request_path, query_string, headers))
コード例 #22
0
def wrap_database_trace(module, object_path, sql, dbapi2_module=None):
    wrap_object(module, object_path, DatabaseTraceWrapper,
                (sql, dbapi2_module))
コード例 #23
0
def instrument(module):
    register_database_client(module, 'DBAPI2', 'single')

    wrap_object(module, 'connect', ConnectionFactory, (module,))
コード例 #24
0
ファイル: error_trace.py プロジェクト: DmitryMaxim18/4Docker
def wrap_error_trace(module, object_path, ignore_errors=[]):
    wrap_object(module, object_path, ErrorTraceWrapper, (ignore_errors, ))
コード例 #25
0
def wrap_memcache_single(module, object_path, product, target, operation):
    wrap_object(module.Client, object_path, MemcacheSingleWrapper,
                (product, target, operation, module))
コード例 #26
0
def wrap_graphql_operation_trace(module, object_path):
    wrap_object(module, object_path, GraphQLOperationTraceWrapper)
コード例 #27
0
def wrap_graphql_resolver_trace(module, object_path):
    wrap_object(module, object_path, GraphQLResolverTraceWrapper)
コード例 #28
0
def wrap_datastore_trace(module, object_path, product, target, operation):
    wrap_object(module, object_path, DatastoreTraceWrapper,
                (product, target, operation))
コード例 #29
0
ファイル: external_trace.py プロジェクト: jimmoffet/VoteBot
def wrap_external_trace(module, object_path, library, url, method=None):
    wrap_object(module, object_path, ExternalTraceWrapper,
                (library, url, method))
コード例 #30
0
def wrap_memcache_trace(module, object_path, command):
    wrap_object(module, object_path, MemcacheTraceWrapper, (command,))