Example #1
0
def patch():
    if getattr(botocore.client, "_datadog_patch", False):
        return
    setattr(botocore.client, "_datadog_patch", True)

    wrapt.wrap_function_wrapper("botocore.client", "BaseClient._make_api_call", patched_api_call)
    Pin(service="aws", app="aws").onto(botocore.client.BaseClient)
Example #2
0
def patch():
    """Instrument Pylons applications"""
    if getattr(pylons.wsgiapp, '_datadog_patch', False):
        return

    setattr(pylons.wsgiapp, '_datadog_patch', True)
    wrapt.wrap_function_wrapper('pylons.wsgiapp', 'PylonsApp.__init__', traced_init)
Example #3
0
def _patch_extensions(_extensions):
    # we must patch extensions all the time (it's pretty harmless) so split
    # from global patching of connections. must be idempotent.
    for _, module, func, wrapper in _extensions:
        if not hasattr(module, func) or isinstance(getattr(module, func), wrapt.ObjectProxy):
            continue
        wrapt.wrap_function_wrapper(module, func, wrapper)
Example #4
0
def patch():
    if getattr(botocore.client, '_datadog_patch', False):
        return
    setattr(botocore.client, '_datadog_patch', True)

    wrapt.wrap_function_wrapper('botocore.client', 'BaseClient._make_api_call', patched_api_call)
    Pin(service='aws', app='aws').onto(botocore.client.BaseClient)
Example #5
0
def patch():
    """Patch the bottle.Bottle class"""
    if getattr(bottle, "_datadog_patch", False):
        return

    setattr(bottle, "_datadog_patch", True)
    wrapt.wrap_function_wrapper("bottle", "Bottle.__init__", traced_init)
Example #6
0
def patch():
    if getattr(pynamodb.connection.base, "_datadog_patch", False):
        return
    setattr(pynamodb.connection.base, "_datadog_patch", True)

    wrapt.wrap_function_wrapper("pynamodb.connection.base", "Connection._make_api_call", patched_api_call)
    Pin(service=None).onto(pynamodb.connection.base.Connection)
Example #7
0
def patch():
    if getattr(aiobotocore.client, '_datadog_patch', False):
        return
    setattr(aiobotocore.client, '_datadog_patch', True)

    wrapt.wrap_function_wrapper('aiobotocore.client', 'AioBaseClient._make_api_call', _wrapped_api_call)
    Pin(service=config.service or "aws", app="aws").onto(aiobotocore.client.AioBaseClient)
Example #8
0
def patch():
    """Instrument Pylons applications"""
    if getattr(pylons.wsgiapp, "_datadog_patch", False):
        return

    setattr(pylons.wsgiapp, "_datadog_patch", True)
    wrapt.wrap_function_wrapper("pylons.wsgiapp", "PylonsApp.__init__",
                                traced_init)
Example #9
0
def patch():
    """Patch the bottle.Bottle class
    """
    if getattr(bottle, '_datadog_patch', False):
        return

    setattr(bottle, '_datadog_patch', True)
    wrapt.wrap_function_wrapper('bottle', 'Bottle.__init__', traced_init)
Example #10
0
def includeme(config):
    # Add our tween just before the default exception handler
    config.add_tween(DD_TWEEN_NAME, over=pyramid.tweens.EXCVIEW)
    # ensure we only patch the renderer once.
    if not isinstance(pyramid.renderers.RendererHelper.render,
                      wrapt.ObjectProxy):
        wrapt.wrap_function_wrapper('pyramid.renderers',
                                    'RendererHelper.render', trace_render)
Example #11
0
def patch():
    if getattr(aiobotocore.client, "_datadog_patch", False):
        return
    setattr(aiobotocore.client, "_datadog_patch", True)

    wrapt.wrap_function_wrapper("aiobotocore.client",
                                "AioBaseClient._make_api_call",
                                _wrapped_api_call)
    Pin(service=config.service or "aws").onto(aiobotocore.client.AioBaseClient)
Example #12
0
def patch():
    """Patch monkey patches psycopg's connection function
    so that the connection's functions are traced.
    """
    if getattr(psycopg2, "_datadog_patch", False):
        return
    setattr(psycopg2, "_datadog_patch", True)

    wrapt.wrap_function_wrapper(psycopg2, "connect", patched_connect)
    _patch_extensions(_psycopg2_extensions)  # do this early just in case
Example #13
0
def patch():
    """ Patch monkey patches psycopg's connection function
        so that the connection's functions are traced.
    """
    if getattr(aiopg, '_datadog_patch', False):
        return
    setattr(aiopg, '_datadog_patch', True)

    wrapt.wrap_function_wrapper(aiopg.connection, '_connect', patched_connect)
    _patch_extensions(_aiopg_extensions)  # do this early just in case
Example #14
0
def patch():
    """
    Patch falcon.API to include contrib.falcon.TraceMiddleware
    by default
    """
    if getattr(falcon, "_datadog_patch", False):
        return

    setattr(falcon, "_datadog_patch", True)
    wrapt.wrap_function_wrapper("falcon", "API.__init__", traced_init)
Example #15
0
def patch():
    import snowflake.connector

    if getattr(snowflake.connector, "_datadog_patch", False):
        return
    setattr(snowflake.connector, "_datadog_patch", True)

    wrapt.wrap_function_wrapper(snowflake.connector, "Connect",
                                patched_connect)
    wrapt.wrap_function_wrapper(snowflake.connector, "connect",
                                patched_connect)
Example #16
0
def patch():
    if getattr(boto.connection, "_datadog_patch", False):
        return
    setattr(boto.connection, "_datadog_patch", True)

    # AWSQueryConnection and AWSAuthConnection are two different classes called by
    # different services for connection.
    # For example EC2 uses AWSQueryConnection and S3 uses AWSAuthConnection
    wrapt.wrap_function_wrapper("boto.connection",
                                "AWSQueryConnection.make_request",
                                patched_query_request)
    wrapt.wrap_function_wrapper("boto.connection",
                                "AWSAuthConnection.make_request",
                                patched_auth_request)
    Pin(service="aws", app="aws").onto(boto.connection.AWSQueryConnection)
    Pin(service="aws", app="aws").onto(boto.connection.AWSAuthConnection)
Example #17
0
def patch():
    if getattr(boto.connection, '_datadog_patch', False):
        return
    setattr(boto.connection, '_datadog_patch', True)

    # AWSQueryConnection and AWSAuthConnection are two different classes called by
    # different services for connection.
    # For exemple EC2 uses AWSQueryConnection and S3 uses AWSAuthConnection
    wrapt.wrap_function_wrapper('boto.connection',
                                'AWSQueryConnection.make_request',
                                patched_query_request)
    wrapt.wrap_function_wrapper('boto.connection',
                                'AWSAuthConnection.make_request',
                                patched_auth_request)
    Pin(service='aws', app='aws').onto(boto.connection.AWSQueryConnection)
    Pin(service='aws', app='aws').onto(boto.connection.AWSAuthConnection)
Example #18
0
def patch():
    wrapt.wrap_function_wrapper("mysql.connector", "connect", _connect)
    # `Connect` is an alias for `connect`, patch it too
    if hasattr(mysql.connector, "Connect"):
        mysql.connector.Connect = mysql.connector.connect
Example #19
0
def patch():
    wrapt.wrap_function_wrapper('mysql.connector', 'connect', _connect)
    # `Connect` is an alias for `connect`, patch it too
    if hasattr(mysql.connector, 'Connect'):
        mysql.connector.Connect = mysql.connector.connect
Example #20
0
def patch():
    wrapt.wrap_function_wrapper('pymysql', 'connect', _connect)
Example #21
0
def patch():
    if getattr(mariadb, "_datadog_patch", False):
        return
    setattr(mariadb, "_datadog_patch", True)
    wrapt.wrap_function_wrapper("mariadb", "connect", _connect)
Example #22
0
def patch():
    wrapt.wrap_function_wrapper("pymysql", "connect", _connect)