Exemple #1
0
    def parse_params(method, url, *args, **kwargs):
        _kwargs = kwargs
        _args = (method, url) + args

        if 'headers' in _kwargs:
            _kwargs['headers'] = process_cross_trace(_kwargs['headers'])
        else:
            _kwargs['headers'] = process_cross_trace(None)

        return _args, _kwargs
def trace_http_headers_init_(wrapped, instance, args, kwargs):
    """
    :return:
    """
    result = wrapped(*args, **kwargs)
    tracker = obtain_current_tracker()
    if tracker and hasattr(instance, 'X-Tingyun-Tx-Data'):
        tracker._called_traced_data = eval(
            instance.headers.get("X-Tingyun-Tx-Data", '{}'))

    process_cross_trace(instance)
    return result
    def parse_params(method, url, *args, **kwargs):
        _kwargs = kwargs
        _args = (method, url) + args
        protocol = 'http' if 'https' not in url else 'https'

        if 'headers' in _kwargs:
            ty_headers, external_id = process_cross_trace(
                _kwargs['headers'], protocol)
            _kwargs['headers'] = ty_headers
        else:
            ty_headers, external_id = process_cross_trace(None, protocol)
            _kwargs['headers'] = ty_headers

        return external_id, _args, _kwargs
Exemple #4
0
        def parse_server(instance, exchange, routing_key, body, properties=None, *_args, **_kwargs):
            """ 获取publish的一些必要信息,优先获取exchange作为metric名字
            :return:
            """
            global publish_headers
            host, port, byte, name = "Unknown", 0, 0, "Unknown"

            try:
                # blocking  和 其他异步生产者,
                connection = getattr(instance, 'connection', None) or getattr(instance, '_connection', None)
                impl = getattr(connection, '_impl', None) or connection
                host = impl.params.host
                port = impl.params.port

                publish_headers = getattr(properties, "headers", {}) or {}
                ty_headers, _external_id = process_cross_trace(None, msg_type='TingyunID')
                if ty_headers:
                    from pika.spec import BasicProperties

                    if not properties:
                        properties = BasicProperties(headers=ty_headers)
                    else:
                        if not getattr(properties, "headers", None):
                            setattr(properties, "headers", ty_headers)
                        elif isinstance(properties.headers, dict):
                            properties.headers.update(ty_headers)

            except Exception as err:
                console.info("Parse RabbitMQ host & port with error %s", err)
                _external_id = None

            _server = (host, port, sys.getsizeof(body), exchange or routing_key, _external_id)
            return _server, exchange, routing_key, body, properties, _args, _kwargs
Exemple #5
0
    def parse_params(method, url, redirect=True, **kw):
        _args = (method, url)
        _kwargs = kw

        if not kw:
            _kwargs = {}

        _kwargs["redirect"] = redirect
        _kwargs["headers"] = process_cross_trace(_kwargs.get("headers", None))

        return _args, _kwargs
Exemple #6
0
    def parse_params(uri, method="GET", body=None, headers=None, **kwargs):
        """
        """
        _args = (uri, )
        _kwarg = kwargs

        if not kwargs:
            _kwarg = {}

        _kwarg["method"] = method
        _kwarg["body"] = body
        _kwarg["headers"] = process_cross_trace(headers)

        return _args, _kwarg
Exemple #7
0
    def parse_params(method, url, redirect=True, **kw):
        _args = (method, url)
        _kwargs = kw
        protocol = 'http' if 'https' not in url else 'https'

        if not kw:
            _kwargs = {}

        ty_headers, external_id = process_cross_trace(
            _kwargs.get("headers", None), protocol)
        _kwargs["redirect"] = redirect
        _kwargs["headers"] = ty_headers

        return external_id, _args, _kwargs
    def parse_params(uri, method="GET", body=None, headers=None, **kwargs):
        """
        """
        _args = (uri, )
        _kwarg = kwargs

        if not kwargs:
            _kwarg = {}

        ty_headers, external_id = process_cross_trace(headers)
        _kwarg["method"] = method
        _kwarg["body"] = body
        _kwarg["headers"] = ty_headers

        return external_id, _args, _kwarg