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, ))
def instrument_sqlite3_dbapi2(module): register_database_client(module, 'SQLite', quoting_style='single+double', instance_info=instance_info) wrap_object(module, 'connect', ConnectionFactory, (module, ))
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))
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,))
def wrap_function_profile(module, object_path, filename, delay=1.0, checkpoint=30): wrap_object(module, object_path, FunctionProfileWrapper, (filename, delay, checkpoint))
def wrap_background_task(module, object_path, application=None, name=None, group=None): wrap_object(module, object_path, BackgroundTaskWrapper, (application, name, group))
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,))
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))
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))
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))
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, ))
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, ))
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)
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,))
def wrap_transaction_name(module, object_path, name=None, group=None, priority=None): return wrap_object(module, object_path, TransactionNameWrapper, (name, group, priority))
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, ), )
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))
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))
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))
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)
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))
def wrap_database_trace(module, object_path, sql, dbapi2_module=None): wrap_object(module, object_path, DatabaseTraceWrapper, (sql, dbapi2_module))
def instrument(module): register_database_client(module, 'DBAPI2', 'single') wrap_object(module, 'connect', ConnectionFactory, (module,))
def wrap_error_trace(module, object_path, ignore_errors=[]): wrap_object(module, object_path, ErrorTraceWrapper, (ignore_errors, ))
def wrap_memcache_single(module, object_path, product, target, operation): wrap_object(module.Client, object_path, MemcacheSingleWrapper, (product, target, operation, module))
def wrap_graphql_operation_trace(module, object_path): wrap_object(module, object_path, GraphQLOperationTraceWrapper)
def wrap_graphql_resolver_trace(module, object_path): wrap_object(module, object_path, GraphQLResolverTraceWrapper)
def wrap_datastore_trace(module, object_path, product, target, operation): wrap_object(module, object_path, DatastoreTraceWrapper, (product, target, operation))
def wrap_external_trace(module, object_path, library, url, method=None): wrap_object(module, object_path, ExternalTraceWrapper, (library, url, method))
def wrap_memcache_trace(module, object_path, command): wrap_object(module, object_path, MemcacheTraceWrapper, (command,))