Search in sources :

Example 51 with V1Span

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

the class SpanConverterTest method client_kindInferredFromAnnotation.

@Test
public void client_kindInferredFromAnnotation() {
    Span v2 = Span.newBuilder().traceId("1").parentId("2").id("3").name("get").localEndpoint(FRONTEND).timestamp(1472470996199000L).duration(1472470996238000L - 1472470996199000L).addAnnotation(1472470996199000L, "cs").build();
    V1Span v1 = V1Span.newBuilder().traceId(1L).parentId(2L).id(3L).name("get").timestamp(1472470996199000L).duration(1472470996238000L - 1472470996199000L).addAnnotation(1472470996199000L, "cs", FRONTEND).addAnnotation(1472470996238000L, "cr", FRONTEND).build();
    assertThat(v2SpanConverter.convert(v2)).usingRecursiveComparison().isEqualTo(v1);
}
Also used : Span(zipkin2.Span) Test(org.junit.Test)

Example 52 with V1Span

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

the class SpanConverterTest method assumesServerWithoutTimestampIsShared.

/**
 * The old v1 format had no means of saying it is shared or not. This uses lack of timestamp as a
 * signal
 */
@Test
public void assumesServerWithoutTimestampIsShared() {
    V1Span v1 = V1Span.newBuilder().traceId(1L).parentId(2L).id(3L).name("get").addAnnotation(1472470996250000L, "sr", BACKEND).addAnnotation(1472470996350000L, "ss", BACKEND).build();
    Span v2 = Span.newBuilder().traceId("1").parentId("2").id("3").name("get").kind(Kind.SERVER).shared(true).localEndpoint(BACKEND).timestamp(1472470996250000L).duration(100000L).build();
    assertThat(v1SpanConverter.convert(v1)).containsExactly(v2);
}
Also used : Span(zipkin2.Span) Test(org.junit.Test)

Example 53 with V1Span

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

the class SpanConverterTest method redundantServiceNameOnAddressAnnotations_serverRetainsClientSocket.

@Test
public void redundantServiceNameOnAddressAnnotations_serverRetainsClientSocket() {
    Span v2 = Span.newBuilder().traceId("1").parentId("2").id("3").kind(Kind.SERVER).name("get").localEndpoint(BACKEND).remoteEndpoint(FRONTEND.toBuilder().serviceName(null).build()).timestamp(1472470996199000L).duration(207000L).build();
    V1Span v1 = V1Span.newBuilder().traceId(1L).parentId(2L).id(3L).name("get").timestamp(1472470996199000L).duration(207000L).addAnnotation(1472470996199000L, "sr", BACKEND).addAnnotation(1472470996406000L, "ss", BACKEND).addBinaryAnnotation("ca", FRONTEND.toBuilder().serviceName("backend").build()).addBinaryAnnotation("sa", BACKEND).build();
    assertThat(v1SpanConverter.convert(v1)).containsExactly(v2);
}
Also used : Span(zipkin2.Span) Test(org.junit.Test)

Example 54 with V1Span

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

the class ThriftCodec method readOne.

@Nullable
public static Span readOne(ReadBuffer buffer) {
    if (buffer.available() == 0)
        return null;
    try {
        V1Span v1Span = new V1ThriftSpanReader().read(buffer);
        List<Span> out = new ArrayList<Span>(1);
        V1SpanConverter.create().convert(v1Span, out);
        return out.get(0);
    } catch (Exception e) {
        throw exceptionReading("Span", e);
    }
}
Also used : ArrayList(java.util.ArrayList) Span(zipkin2.Span) V1Span(zipkin2.v1.V1Span) EOFException(java.io.EOFException) BufferUnderflowException(java.nio.BufferUnderflowException) V1Span(zipkin2.v1.V1Span)

Example 55 with V1Span

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

the class ThriftCodec method readList.

public static boolean readList(ReadBuffer buffer, Collection<Span> out) {
    int length = buffer.available();
    if (length == 0)
        return false;
    try {
        int listLength = readListLength(buffer);
        if (listLength == 0)
            return false;
        V1ThriftSpanReader reader = new V1ThriftSpanReader();
        V1SpanConverter converter = V1SpanConverter.create();
        for (int i = 0; i < listLength; i++) {
            V1Span v1Span = reader.read(buffer);
            converter.convert(v1Span, out);
        }
    } catch (Exception e) {
        throw exceptionReading("List<Span>", e);
    }
    return true;
}
Also used : V1SpanConverter(zipkin2.v1.V1SpanConverter) EOFException(java.io.EOFException) BufferUnderflowException(java.nio.BufferUnderflowException) V1Span(zipkin2.v1.V1Span)

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