Search in sources :

Example 21 with Kind

use of zipkin2.Span.Kind 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 22 with Kind

use of zipkin2.Span.Kind 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 23 with Kind

use of zipkin2.Span.Kind 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 24 with Kind

use of zipkin2.Span.Kind in project zipkin by openzipkin.

the class SpanConverterTest method server_shared_v1_no_timestamp_duration.

@Test
public void server_shared_v1_no_timestamp_duration() {
    Span v2 = Span.newBuilder().traceId("1").parentId('2').id("3").name("get").kind(Kind.SERVER).shared(true).localEndpoint(BACKEND).timestamp(1472470996199000L).duration(207000L).build();
    V1Span v1 = V1Span.newBuilder().traceId("1").parentId('2').id("3").name("get").addAnnotation(1472470996199000L, "sr", BACKEND).addAnnotation(1472470996406000L, "ss", BACKEND).build();
    assertThat(v2SpanConverter.convert(v2)).usingRecursiveComparison().isEqualTo(v1);
    assertThat(v1SpanConverter.convert(v1)).containsExactly(v2);
}
Also used : Span(zipkin2.Span) Test(org.junit.Test)

Example 25 with Kind

use of zipkin2.Span.Kind in project zipkin by openzipkin.

the class SpanConverterTest method parsesSharedFlagFromRPCSpan.

/**
 * This emulates a situation in mysql where the row representing a span has the client's timestamp
 */
@Test
public void parsesSharedFlagFromRPCSpan() {
    V1Span v1 = V1Span.newBuilder().traceId(1L).parentId(2L).id(3L).name("get").timestamp(10).addAnnotation(20, "sr", BACKEND).addAnnotation(30, "ss", BACKEND).build();
    Span v2 = Span.newBuilder().traceId("1").parentId("2").id("3").name("get").kind(Kind.SERVER).shared(true).localEndpoint(BACKEND).timestamp(20).duration(10L).build();
    assertThat(v1SpanConverter.convert(v1)).containsExactly(v2);
}
Also used : Span(zipkin2.Span) Test(org.junit.Test)

Aggregations

Span (zipkin2.Span)82 Test (org.junit.Test)54 Endpoint (zipkin2.Endpoint)25 Test (org.junit.jupiter.api.Test)17 V1Span (zipkin2.v1.V1Span)10 TraceSpan (com.google.devtools.cloudtrace.v1.TraceSpan)8 IOException (java.io.IOException)6 Map (java.util.Map)5 TestObjects.newClientSpan (zipkin2.TestObjects.newClientSpan)5 Tracer (brave.Tracer)4 Tracing (brave.Tracing)4 Trace (com.google.devtools.cloudtrace.v1.Trace)4 ArrayList (java.util.ArrayList)4 List (java.util.List)4 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)4 Before (org.junit.Before)4 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)4 Span (brave.Span)3 Sampler (brave.sampler.Sampler)3 Annotation (zipkin2.Annotation)3