Ejemplo n.º 1
0
 def do_POST(self):
   content_length = self.headers.get('content-length') if PY3 else self.headers.getheader('content-length')
   thrift_trace = self.rfile.read(int(content_length))
   json_trace = convert_spans(thrift_trace, Encoding.V1_JSON, Encoding.V1_THRIFT)
   trace = json.loads(json_trace)
   self.__class__.traces.append(trace)
   self.send_response(200)
 def do_POST(self):
   content_length = self.headers.get('content-length') if PY3 else self.headers.getheader('content-length')
   thrift_trace = self.rfile.read(int(content_length))
   json_trace = convert_spans(thrift_trace, Encoding.V1_JSON, Encoding.V1_THRIFT)
   trace = json.loads(json_trace)
   self.__class__.traces.append(trace)
   self.send_response(200)
Ejemplo n.º 3
0
def test_convert_spans_v2_json_to_v2_json():
    spans, _, _, _ = generate_list_of_spans(Encoding.V2_JSON)

    converted_spans = convert_spans(spans=spans,
                                    output_encoding=Encoding.V2_JSON)

    assert detect_span_version_and_encoding(
        converted_spans) == Encoding.V2_JSON
Ejemplo n.º 4
0
 def do_POST(self):
   content_length = self.headers.get('content-length')
   thrift_trace = self.rfile.read(int(content_length))
   json_trace = convert_spans(thrift_trace, Encoding.V1_JSON, Encoding.V1_THRIFT)
   trace = json.loads(json_trace)
   for span in trace:
     trace_id = span["traceId"]
     self.__class__.traces[trace_id].append(span)
   self.send_response(200)
Ejemplo n.º 5
0
def test_encoding():
    thrift_spans, zipkin_attrs, inner_span_id, ts = \
        generate_list_of_spans(Encoding.V1_THRIFT)

    json_spans = convert_spans(thrift_spans, Encoding.V2_JSON)

    inner_span, root_span = json.loads(json_spans)

    assert root_span == {
        'traceId': zipkin_attrs.trace_id,
        'name': 'test_span_name',
        'parentId': zipkin_attrs.parent_span_id,
        'id': zipkin_attrs.span_id,
        'timestamp': us(ts),
        'duration': us(10),
        'kind': 'CLIENT',
        'shared': True,
        'localEndpoint': {
            'ipv4': '10.0.0.0',
            'port': 8080,
            'serviceName': 'test_service_name',
        },
        'remoteEndpoint': {
            'ipv6': '2001:db8:85a3::8a2e:370:7334',
            'port': 8888,
            'serviceName': 'sa_service',
        },
        'tags': {
            'some_key': 'some_value'
        },
    }

    assert inner_span == {
        'traceId': zipkin_attrs.trace_id,
        'name': 'inner_span',
        'parentId': zipkin_attrs.span_id,
        'id': inner_span_id,
        'timestamp': us(ts),
        'duration': us(5),
        'localEndpoint': {
            'ipv4': '10.0.0.0',
            'port': 8080,
            'serviceName': 'test_service_name',
        },
        'annotations': [{
            'timestamp': us(ts),
            'value': 'ws'
        }],
    }
Ejemplo n.º 6
0
def test_encoding():
    thrift_spans, zipkin_attrs, inner_span_id, ts = generate_list_of_spans(
        Encoding.V1_THRIFT)

    json_spans = convert_spans(thrift_spans, Encoding.V2_JSON)

    inner_span, root_span = json.loads(json_spans)

    assert root_span == {
        "traceId": zipkin_attrs.trace_id,
        "name": "test_span_name",
        "parentId": zipkin_attrs.parent_span_id,
        "id": zipkin_attrs.span_id,
        "timestamp": us(ts),
        "duration": us(10),
        "kind": "CLIENT",
        "localEndpoint": {
            "ipv4": "10.0.0.0",
            "port": 8080,
            "serviceName": "test_service_name",
        },
        "remoteEndpoint": {
            "ipv6": "2001:db8:85a3::8a2e:370:7334",
            "port": 8888,
            "serviceName": "sa_service",
        },
        "tags": {
            "some_key": "some_value"
        },
    }

    assert inner_span == {
        "traceId": zipkin_attrs.trace_id,
        "name": "inner_span",
        "parentId": zipkin_attrs.span_id,
        "id": inner_span_id,
        "timestamp": us(ts),
        "duration": us(5),
        "localEndpoint": {
            "ipv4": "10.0.0.0",
            "port": 8080,
            "serviceName": "test_service_name",
        },
        "annotations": [{
            "timestamp": us(ts),
            "value": "ws"
        }],
    }