Search in sources :

Example 6 with V1Span

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

the class SpanConverterTest method localSpan_emptyComponent.

@Test
public void localSpan_emptyComponent() {
    Span v2 = Span.newBuilder().traceId("1").id("2").name("local").localEndpoint(Endpoint.newBuilder().serviceName("frontend").build()).timestamp(1472470996199000L).duration(207000L).build();
    V1Span v1 = V1Span.newBuilder().traceId(1L).id(2L).name("local").timestamp(1472470996199000L).duration(207000L).addBinaryAnnotation("lc", "", Endpoint.newBuilder().serviceName("frontend").build()).build();
    assertThat(v2SpanConverter.convert(v2)).usingRecursiveComparison().isEqualTo(v1);
    assertThat(v1SpanConverter.convert(v1)).containsExactly(v2);
}
Also used : Span(zipkin2.Span) Test(org.junit.Test)

Example 7 with V1Span

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

the class SpanConverterTest method server.

@Test
public void server() {
    Span v2 = Span.newBuilder().traceId("1").id("2").name("get").kind(Kind.SERVER).localEndpoint(BACKEND).remoteEndpoint(FRONTEND).timestamp(1472470996199000L).duration(207000L).putTag("http.path", "/api").putTag("finagle.version", "6.45.0").build();
    V1Span v1 = V1Span.newBuilder().traceId(1L).id(2L).name("get").timestamp(1472470996199000L).duration(207000L).addAnnotation(1472470996199000L, "sr", BACKEND).addAnnotation(1472470996406000L, "ss", BACKEND).addBinaryAnnotation("http.path", "/api", BACKEND).addBinaryAnnotation("finagle.version", "6.45.0", BACKEND).addBinaryAnnotation("ca", FRONTEND).build();
    assertThat(v2SpanConverter.convert(v2)).usingRecursiveComparison().isEqualTo(v1);
    assertThat(v1SpanConverter.convert(v1)).containsExactly(v2);
}
Also used : Span(zipkin2.Span) Test(org.junit.Test)

Example 8 with V1Span

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

the class SpanConverterTest method oneway_loopback.

@Test
public void oneway_loopback() {
    V1Span v1 = V1Span.newBuilder().traceId(1L).parentId(2L).id(3L).name("get").addAnnotation(1472470996199000L, "cs", FRONTEND).addAnnotation(1472470996250000L, "sr", FRONTEND).build();
    Span.Builder newBuilder = Span.newBuilder().traceId("1").parentId("2").id("3").name("get");
    Span clientV2 = newBuilder.clone().kind(Kind.CLIENT).localEndpoint(FRONTEND).timestamp(1472470996199000L).build();
    Span serverV2 = newBuilder.clone().kind(Kind.SERVER).shared(true).localEndpoint(FRONTEND).timestamp(1472470996250000L).build();
    assertThat(v1SpanConverter.convert(v1)).containsExactly(clientV2, serverV2);
}
Also used : Span(zipkin2.Span) Test(org.junit.Test)

Example 9 with V1Span

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

the class SpanConverterTest method clientAndServer_loopback.

@Test
public void clientAndServer_loopback() {
    V1Span v1 = V1Span.newBuilder().traceId(1L).parentId(2L).id(3L).name("get").timestamp(1472470996199000L).duration(207000L).addAnnotation(1472470996199000L, "cs", FRONTEND).addAnnotation(1472470996250000L, "sr", FRONTEND).addAnnotation(1472470996350000L, "ss", FRONTEND).addAnnotation(1472470996406000L, "cr", FRONTEND).build();
    Span.Builder newBuilder = Span.newBuilder().traceId("1").parentId("2").id("3").name("get");
    Span clientV2 = newBuilder.clone().kind(Kind.CLIENT).localEndpoint(FRONTEND).timestamp(1472470996199000L).duration(207000L).build();
    Span serverV2 = newBuilder.clone().kind(Kind.SERVER).shared(true).localEndpoint(FRONTEND).timestamp(1472470996250000L).duration(100000L).build();
    assertThat(v1SpanConverter.convert(v1)).containsExactly(clientV2, serverV2);
}
Also used : Span(zipkin2.Span) Test(org.junit.Test)

Example 10 with V1Span

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

the class V1JsonSpanReader method readList.

public boolean readList(ReadBuffer buffer, Collection<Span> out) {
    if (buffer.available() == 0)
        return false;
    V1SpanConverter converter = V1SpanConverter.create();
    JsonReader reader = new JsonReader(buffer);
    try {
        reader.beginArray();
        if (!reader.hasNext())
            return false;
        while (reader.hasNext()) {
            V1Span result = fromJson(reader);
            converter.convert(result, out);
        }
        reader.endArray();
        return true;
    } catch (Exception e) {
        throw exceptionReading("List<Span>", e);
    }
}
Also used : V1SpanConverter(zipkin2.v1.V1SpanConverter) JsonReader(zipkin2.internal.JsonCodec.JsonReader) IOException(java.io.IOException) 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