Search in sources :

Example 26 with Kind

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

the class SpanConverterTest method client_unfinished.

@Test
public void client_unfinished() {
    Span v2 = Span.newBuilder().traceId("1").parentId("2").id("3").name("get").kind(Kind.CLIENT).localEndpoint(FRONTEND).timestamp(1472470996199000L).addAnnotation(1472470996238000L, "ws").build();
    V1Span v1 = V1Span.newBuilder().traceId(1L).parentId(2L).id(3L).name("get").timestamp(1472470996199000L).addAnnotation(1472470996199000L, "cs", FRONTEND).addAnnotation(1472470996238000L, "ws", 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 27 with Kind

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

the class SpanConverterTest method client.

@Test
public void client() {
    Span v2 = Span.newBuilder().traceId("1").parentId("2").id("3").name("get").kind(Kind.CLIENT).localEndpoint(FRONTEND).remoteEndpoint(BACKEND).timestamp(1472470996199000L).duration(207000L).addAnnotation(1472470996238000L, "ws").addAnnotation(1472470996403000L, "wr").putTag("http.path", "/api").putTag("clnt/finagle.version", "6.45.0").build();
    V1Span v1 = V1Span.newBuilder().traceId(1L).parentId(2L).id(3L).name("get").timestamp(1472470996199000L).duration(207000L).addAnnotation(1472470996199000L, "cs", FRONTEND).addAnnotation(1472470996238000L, "ws", // ts order retained
    FRONTEND).addAnnotation(1472470996403000L, "wr", FRONTEND).addAnnotation(1472470996406000L, "cr", FRONTEND).addBinaryAnnotation("http.path", "/api", FRONTEND).addBinaryAnnotation("clnt/finagle.version", "6.45.0", FRONTEND).addBinaryAnnotation("sa", 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 28 with Kind

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

the class SpanConverterTest method producerAndConsumer.

/**
 * shared v1 IDs for messaging spans isn't supported, but shouldn't break
 */
@Test
public void producerAndConsumer() {
    V1Span v1 = V1Span.newBuilder().traceId(1L).parentId(2L).id(3L).name("whatev").addAnnotation(1472470996199000L, "ms", FRONTEND).addAnnotation(1472470996238000L, "ws", FRONTEND).addAnnotation(1472470996403000L, "wr", BACKEND).addAnnotation(1472470996406000L, "mr", BACKEND).addBinaryAnnotation("ma", kafka).build();
    Span.Builder newBuilder = Span.newBuilder().traceId("1").parentId("2").id("3").name("whatev");
    Span producer = newBuilder.clone().kind(Kind.PRODUCER).localEndpoint(FRONTEND).remoteEndpoint(kafka).timestamp(1472470996199000L).duration(1472470996238000L - 1472470996199000L).build();
    Span consumer = newBuilder.clone().kind(Kind.CONSUMER).shared(true).localEndpoint(BACKEND).remoteEndpoint(kafka).timestamp(1472470996403000L).duration(1472470996406000L - 1472470996403000L).build();
    assertThat(v1SpanConverter.convert(v1)).containsExactly(producer, consumer);
}
Also used : Span(zipkin2.Span) Test(org.junit.Test)

Example 29 with Kind

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

the class SpanConverterTest method producer.

@Test
public void producer() {
    V1Span v1 = V1Span.newBuilder().traceId(1L).parentId(2L).id(3L).name("send").addAnnotation(1472470996199000L, "ms", FRONTEND).build();
    Span v2 = Span.newBuilder().traceId("1").parentId("2").id("3").name("send").kind(Kind.PRODUCER).localEndpoint(FRONTEND).timestamp(1472470996199000L).build();
    assertThat(v1SpanConverter.convert(v1)).containsExactly(v2);
}
Also used : Span(zipkin2.Span) Test(org.junit.Test)

Example 30 with Kind

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

the class SpanConverterTest method client_missingCs.

/**
 * Fix a v1 reported half in new style and half in old style, ex via a bridge
 */
@Test
public void client_missingCs() {
    Span v2 = Span.newBuilder().traceId("1").id("2").name("get").kind(Kind.CLIENT).localEndpoint(FRONTEND).timestamp(1472470996199000L).duration(207000L).build();
    V1Span v1 = V1Span.newBuilder().traceId("1").id("2").name("get").timestamp(1472470996199000L).duration(207000L).addAnnotation(1472470996406000L, "cs", FRONTEND).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