Search in sources :

Example 81 with Span

use of com.google.devtools.cloudtrace.v2.Span in project zipkin by openzipkin.

the class SpanNodeTest method build_noChildLeftBehind.

@Test
public void build_noChildLeftBehind() {
    List<Span> spans = asList(Span.newBuilder().traceId("a").id("b").name("root-0").build(), Span.newBuilder().traceId("a").parentId("b").id("c").name("child-0").build(), Span.newBuilder().traceId("a").parentId("b").id("d").name("child-1").build(), Span.newBuilder().traceId("a").id("e").name("lost-0").build(), Span.newBuilder().traceId("a").id("f").name("lost-1").build());
    int treeSize = 0;
    SpanNode tree = new SpanNode.Builder(logger).build(spans);
    Iterator<SpanNode> iter = tree.traverse();
    while (iter.hasNext()) {
        iter.next();
        treeSize++;
    }
    assertThat(treeSize).isEqualTo(spans.size());
    assertThat(messages).containsExactly("building trace tree: traceId=000000000000000a", "attributing span missing parent to root: traceId=000000000000000a, rootSpanId=000000000000000b, spanId=000000000000000e", "attributing span missing parent to root: traceId=000000000000000a, rootSpanId=000000000000000b, spanId=000000000000000f");
}
Also used : Span(zipkin2.Span) Endpoint(zipkin2.Endpoint) Test(org.junit.Test)

Example 82 with Span

use of com.google.devtools.cloudtrace.v2.Span in project zipkin by openzipkin.

the class V1JsonSpanWriterTest method writesEmptyServiceName.

@Test
public void writesEmptyServiceName() {
    Span span = CLIENT_SPAN.toBuilder().localEndpoint(Endpoint.newBuilder().ip("127.0.0.1").build()).build();
    writer.write(span, buf);
    assertThat(new String(bytes, UTF_8)).contains("\"value\":\"foo\",\"endpoint\":{\"serviceName\":\"\",\"ipv4\":\"127.0.0.1\"}");
}
Also used : Span(zipkin2.Span) Test(org.junit.Test)

Example 83 with Span

use of com.google.devtools.cloudtrace.v2.Span in project zipkin by openzipkin.

the class V2SpanWriterTest method omitsEmptySpanName.

@Test
public void omitsEmptySpanName() {
    Span span = Span.newBuilder().traceId("7180c278b62e8f6a216a2aea45d08fc9").parentId("6b221d5bc9e6496c").id("5b4185666d50f68b").build();
    writer.write(span, buf);
    assertThat(new String(bytes, UTF_8)).doesNotContain("name");
}
Also used : Span(zipkin2.Span) Test(org.junit.Test)

Example 84 with Span

use of com.google.devtools.cloudtrace.v2.Span in project zipkin by openzipkin.

the class SpanConverterTest method onlyAddressAnnotations.

@Test
public void onlyAddressAnnotations() {
    V1Span v1 = V1Span.newBuilder().traceId(1).parentId(2).id(3).name("rpc").addBinaryAnnotation("ca", FRONTEND).addBinaryAnnotation("sa", BACKEND).build();
    Span v2 = Span.newBuilder().traceId("1").parentId("2").id("3").name("rpc").localEndpoint(FRONTEND).remoteEndpoint(BACKEND).build();
    assertThat(v1SpanConverter.convert(v1)).containsExactly(v2);
}
Also used : Span(zipkin2.Span) Test(org.junit.Test)

Example 85 with Span

use of com.google.devtools.cloudtrace.v2.Span in project zipkin by openzipkin.

the class SpanConverterTest method lateRemoteEndpoint_ss.

/**
 * Late flushed data on a v2 span
 */
@Test
public void lateRemoteEndpoint_ss() {
    Span v2 = Span.newBuilder().traceId("1").id("2").name("get").kind(Kind.SERVER).localEndpoint(BACKEND).remoteEndpoint(FRONTEND).addAnnotation(1472470996199000L, "ss").build();
    V1Span v1 = V1Span.newBuilder().traceId(1L).id(2L).name("get").addAnnotation(1472470996199000L, "ss", 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)

Aggregations

Span (zipkin2.Span)290 Test (org.junit.Test)192 Test (org.junit.jupiter.api.Test)67 TestObjects.newClientSpan (zipkin2.TestObjects.newClientSpan)41 Endpoint (zipkin2.Endpoint)37 ArrayList (java.util.ArrayList)24 V1Span (zipkin2.v1.V1Span)17 List (java.util.List)14 AggregateCall (zipkin2.internal.AggregateCall)13 TraceSpan (com.google.devtools.cloudtrace.v1.TraceSpan)12 Arrays.asList (java.util.Arrays.asList)9 Map (java.util.Map)9 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)9 Span (com.google.devtools.cloudtrace.v2.Span)8 LinkedHashMap (java.util.LinkedHashMap)8 Trace (com.google.devtools.cloudtrace.v1.Trace)7 Span (zipkin2.proto3.Span)7 SpanData (io.opencensus.trace.export.SpanData)6 SpanCustomizer (brave.SpanCustomizer)5 IOException (java.io.IOException)5