Search in sources :

Example 21 with V1Span

use of zipkin2.v1.V1Span in project zipkin by openzipkin.

the class V1SpanConverterTest method convert_sa_incorrect_value.

@Test
public void convert_sa_incorrect_value() {
    V1Span v1 = V1Span.newBuilder().traceId(1L).id(2L).addAnnotation(1472470996199000L, "cs", FRONTEND).addBinaryAnnotation("sa", "1", BACKEND).build();
    Span v2 = Span.newBuilder().traceId("1").id("2").kind(Kind.CLIENT).timestamp(1472470996199000L).localEndpoint(FRONTEND).remoteEndpoint(BACKEND).build();
    assertThat(v1SpanConverter.convert(v1)).containsExactly(v2);
}
Also used : Span(zipkin2.Span) Test(org.junit.Test)

Example 22 with V1Span

use of zipkin2.v1.V1Span in project zipkin by openzipkin.

the class V1SpanConverterTest method convert_ma.

@Test
public void convert_ma() {
    V1Span v1 = V1Span.newBuilder().traceId(1L).id(2L).addAnnotation(1472470996199000L, "mr", BACKEND).addBinaryAnnotation("ma", kafka).build();
    Span v2 = Span.newBuilder().traceId("1").id("2").kind(Kind.CONSUMER).timestamp(1472470996199000L).localEndpoint(BACKEND).remoteEndpoint(kafka).build();
    assertThat(v1SpanConverter.convert(v1)).containsExactly(v2);
}
Also used : Span(zipkin2.Span) Test(org.junit.Test)

Example 23 with V1Span

use of zipkin2.v1.V1Span in project zipkin by openzipkin.

the class V1SpanConverterTest method convert_sa.

@Test
public void convert_sa() {
    V1Span v1 = V1Span.newBuilder().traceId(1L).id(2L).addAnnotation(1472470996199000L, "cs", FRONTEND).addBinaryAnnotation("sa", BACKEND).build();
    Span v2 = Span.newBuilder().traceId("1").id("2").kind(Kind.CLIENT).timestamp(1472470996199000L).localEndpoint(FRONTEND).remoteEndpoint(BACKEND).build();
    assertThat(v1SpanConverter.convert(v1)).containsExactly(v2);
}
Also used : Span(zipkin2.Span) Test(org.junit.Test)

Example 24 with V1Span

use of zipkin2.v1.V1Span in project zipkin by openzipkin.

the class V1ThriftSpanWriter method sizeInBytes.

@Override
public int sizeInBytes(Span value) {
    V1Span v1Span = converter.convert(value);
    int endpointSize = value.localEndpoint() != null ? ThriftEndpointCodec.sizeInBytes(value.localEndpoint()) : 0;
    // TRACE_ID
    int sizeInBytes = 3 + 8;
    // TRACE_ID_HIGH
    if (v1Span.traceIdHigh() != 0)
        sizeInBytes += 3 + 8;
    // PARENT_ID
    if (v1Span.parentId() != 0)
        sizeInBytes += 3 + 8;
    // ID
    sizeInBytes += 3 + 8;
    // NAME
    sizeInBytes += 3 + 4;
    if (value.name() != null)
        sizeInBytes += utf8SizeInBytes(value.name());
    // we write list thriftFields even when empty to match finagle serialization
    // ANNOTATION field + list overhead
    sizeInBytes += 3 + 5;
    for (int i = 0, length = v1Span.annotations().size(); i < length; i++) {
        int valueSize = utf8SizeInBytes(v1Span.annotations().get(i).value());
        sizeInBytes += ThriftAnnotationWriter.sizeInBytes(valueSize, endpointSize);
    }
    // BINARY_ANNOTATION field + list overhead
    sizeInBytes += 3 + 5;
    for (int i = 0, length = v1Span.binaryAnnotations().size(); i < length; i++) {
        V1BinaryAnnotation b = v1Span.binaryAnnotations().get(i);
        int keySize = utf8SizeInBytes(b.key());
        if (b.stringValue() != null) {
            int valueSize = utf8SizeInBytes(b.stringValue());
            sizeInBytes += ThriftBinaryAnnotationWriter.sizeInBytes(keySize, valueSize, endpointSize);
        } else {
            int remoteEndpointSize = ThriftEndpointCodec.sizeInBytes(b.endpoint());
            sizeInBytes += ThriftBinaryAnnotationWriter.sizeInBytes(keySize, 1, remoteEndpointSize);
        }
    }
    // DEBUG
    if (v1Span.debug() != null)
        sizeInBytes += 3 + 1;
    // TIMESTAMP
    if (v1Span.timestamp() != 0L)
        sizeInBytes += 3 + 8;
    // DURATION
    if (v1Span.duration() != 0L)
        sizeInBytes += 3 + 8;
    // TYPE_STOP
    sizeInBytes++;
    return sizeInBytes;
}
Also used : V1BinaryAnnotation(zipkin2.v1.V1BinaryAnnotation) Endpoint(zipkin2.Endpoint) V1Span(zipkin2.v1.V1Span)

Example 25 with V1Span

use of zipkin2.v1.V1Span in project zipkin by openzipkin.

the class V1ThriftSpanWriter method writeBinaryAnnotations.

static void writeBinaryAnnotations(WriteBuffer buffer, V1Span v1Span, byte[] endpointBytes) {
    int binaryAnnotationCount = v1Span.binaryAnnotations().size();
    ThriftCodec.writeListBegin(buffer, binaryAnnotationCount);
    for (int i = 0; i < binaryAnnotationCount; i++) {
        V1BinaryAnnotation a = v1Span.binaryAnnotations().get(i);
        byte[] ep = a.stringValue() != null ? endpointBytes : legacyEndpointBytes(a.endpoint());
        ThriftBinaryAnnotationWriter.write(a.key(), a.stringValue(), ep, buffer);
    }
}
Also used : V1BinaryAnnotation(zipkin2.v1.V1BinaryAnnotation) Endpoint(zipkin2.Endpoint)

Aggregations

Span (zipkin2.Span)44 Test (org.junit.Test)41 Endpoint (zipkin2.Endpoint)8 V1Span (zipkin2.v1.V1Span)7 V1BinaryAnnotation (zipkin2.v1.V1BinaryAnnotation)4 EOFException (java.io.EOFException)3 BufferUnderflowException (java.nio.BufferUnderflowException)3 V1Annotation (zipkin2.v1.V1Annotation)3 V1SpanConverter (zipkin2.v1.V1SpanConverter)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 Annotation (zipkin2.Annotation)1 JsonReader (zipkin2.internal.JsonCodec.JsonReader)1