def wrap_sqlalchemy():
    with lumigo_safe_execute("wrap sqlalchemy"):
        if importlib.util.find_spec("sqlalchemy") and listen:
            get_logger().debug("wrapping sqlalchemy")
            wrap_function_wrapper(
                "sqlalchemy.engine.strategies", "DefaultEngineStrategy.create", execute_wrapper
            )
Example #2
0
def wrap_redis():
    with lumigo_safe_execute("wrap redis"):
        if importlib.util.find_spec("redis"):
            get_logger().debug("wrapping redis")
            wrap_function_wrapper("redis.client", "Redis.execute_command",
                                  execute_command_wrapper)
            wrap_function_wrapper("redis.client", "Pipeline.execute",
                                  execute_wrapper)
Example #3
0
def wrap_http_calls():
    global already_wrapped
    if not already_wrapped:
        with lumigo_safe_execute("wrap http calls"):
            get_logger().debug("wrapping the http request")
            wrap_function_wrapper("http.client", "HTTPConnection.send", _request_wrapper)
            wrap_function_wrapper("botocore.awsrequest", "AWSRequest.__init__", _putheader_wrapper)
            wrap_function_wrapper("http.client", "HTTPConnection.getresponse", _response_wrapper)
            wrap_function_wrapper("http.client", "HTTPResponse.read", _read_wrapper)
            if importlib.util.find_spec("urllib3"):
                wrap_function_wrapper(
                    "urllib3.response", "HTTPResponse.read_chunked", _read_stream_wrapper
                )
            already_wrapped = True
Example #4
0
def wrap_aiohttp():
    with lumigo_safe_execute("wrap http calls"):
        get_logger().debug("wrapping http requests")
        if aiohttp:
            trace_config = aiohttp.TraceConfig()
            trace_config.on_request_start.append(on_request_start)
            trace_config.on_request_chunk_sent.append(on_request_chunk_sent)
            trace_config.on_request_end.append(on_request_end)
            trace_config.on_response_chunk_received.append(on_response_chunk_received)
            trace_config.on_request_exception.append(on_request_exception)
            wrap_function_wrapper(
                "aiohttp.client",
                "ClientSession.__init__",
                aiohttp_trace_configs_wrapper(trace_config),
            )
def wrap_http_calls():
    with lumigo_safe_execute("wrap http calls"):
        get_logger().debug("wrapping http requests")
        wrap_function_wrapper("http.client", "HTTPConnection.send",
                              _http_send_wrapper)
        wrap_function_wrapper("http.client", "HTTPConnection.request",
                              _headers_reminder_wrapper)
        if importlib.util.find_spec("botocore"):
            wrap_function_wrapper("botocore.awsrequest", "AWSRequest.__init__",
                                  _putheader_wrapper)
        wrap_function_wrapper("http.client", "HTTPConnection.getresponse",
                              _response_wrapper)
        wrap_function_wrapper("http.client", "HTTPResponse.read",
                              _read_wrapper)
        if importlib.util.find_spec("urllib3"):
            wrap_function_wrapper("urllib3.response",
                                  "HTTPResponse.read_chunked",
                                  _read_stream_wrapper)
        if importlib.util.find_spec("requests"):
            wrap_function_wrapper("requests.api", "request", _requests_wrapper)