Ejemplo n.º 1
0
    def call(self, module, method, wrapped, instance, args, kwargs):
        if 'method' in kwargs:
            method = kwargs['method']
        else:
            method = args[0]

        if 'url' in kwargs:
            url = kwargs['url']
        else:
            url = args[1]

        signature = method.upper()

        if url:
            parsed_url = urlparse.urlparse(url)
            host = parsed_url.hostname or " "
            signature += " " + host

            if parsed_url.port and \
               default_ports.get(parsed_url.scheme) != parsed_url.port:
                signature += ":" + str(parsed_url.port)

        with trace(signature, "ext.http.requests",
                   {'url': url}, leaf=True):
            return wrapped(*args, **kwargs)
Ejemplo n.º 2
0
def get_host_from_url(url):
    parsed_url = urlparse.urlparse(url)
    host = parsed_url.hostname or " "

    if (parsed_url.port
            and default_ports.get(parsed_url.scheme) != parsed_url.port):
        host += ":" + str(parsed_url.port)

    return host
Ejemplo n.º 3
0
def get_host_from_url(url):
    parsed_url = urlparse.urlparse(url)
    host = parsed_url.hostname or " "

    if (
        parsed_url.port and
        default_ports.get(parsed_url.scheme) != parsed_url.port
    ):
        host += ":" + str(parsed_url.port)

    return host
Ejemplo n.º 4
0
    def call(self, module, method, wrapped, instance, args, kwargs):
        signature = "psycopg2.connect"

        host = kwargs.get('host')
        if host:
            signature += " " + str(host)

            port = kwargs.get('port')
            if port:
                port = str(port)
                if int(port) != default_ports.get("postgresql"):
                    signature += ":" + port
        else:
            # Parse connection string and extract host/port
            pass

        with trace(signature, "db.postgreql.connect"):
            return PGConnectionProxy(wrapped(*args, **kwargs))
Ejemplo n.º 5
0
    def call(self, module, method, wrapped, instance, args, kwargs):
        signature = "psycopg2.connect"

        host = kwargs.get('host')
        if host:
            signature += " " + str(host)

            port = kwargs.get('port')
            if port:
                port = str(port)
                if int(port) != default_ports.get("postgresql"):
                    signature += ":" + port
        else:
            # Parse connection string and extract host/port
            pass

        with self.client.capture_trace(signature, "db.postgreql.connect"):
            return PGConnectionProxy(wrapped(*args, **kwargs), self.client)
Ejemplo n.º 6
0
    def call(self, module, method, wrapped, instance, args, kwargs):
        if 'method' in kwargs:
            method = kwargs['method']
        else:
            method = args[0]

        host = instance.host

        if instance.port != default_ports.get(instance.scheme):
            host += ":" + str(instance.port)

        if 'url' in kwargs:
            url = kwargs['url']
        else:
            url = args[1]

        signature = method.upper() + " " + host

        url = instance.scheme + "://" + host + url

        with trace(signature, "ext.http.urllib3", {'url': url}, leaf=True):
            return wrapped(*args, **kwargs)
Ejemplo n.º 7
0
    def call(self, module, method, wrapped, instance, args, kwargs):
        if 'method' in kwargs:
            method = kwargs['method']
        else:
            method = args[0]

        host = instance.host

        if instance.port != default_ports.get(instance.scheme):
            host += ":" + str(instance.port)

        if 'url' in kwargs:
            url = kwargs['url']
        else:
            url = args[1]

        signature = method.upper() + " " + host

        url = instance.scheme + "://" + host + url

        with self.client.capture_trace(signature, "ext.http.urllib3",
                                       {'url': url}, leaf=True):
            return wrapped(*args, **kwargs)