Search in sources :

Example 86 with Span

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

the class InMemoryStorageTest method getTagsAndThenValues.

@Test
public void getTagsAndThenValues() throws IOException {
    Span span1 = Span.newBuilder().traceId("1").id("1").name("root").localEndpoint(Endpoint.newBuilder().serviceName("app").build()).putTag("environment", "dev").putTag("http.method", "GET").timestamp(TODAY * 1000).build();
    Span span2 = Span.newBuilder().traceId("1").parentId("1").id("2").localEndpoint(Endpoint.newBuilder().serviceName("app").build()).putTag("environment", "dev").putTag("http.method", "POST").putTag("http.path", "/users").timestamp(TODAY * 1000).build();
    Span span3 = Span.newBuilder().traceId("2").id("3").name("root").localEndpoint(Endpoint.newBuilder().serviceName("app").build()).putTag("environment", "dev").putTag("http.method", "GET").timestamp(TODAY * 1000).build();
    Span span4 = Span.newBuilder().traceId("2").parentId("3").id("4").localEndpoint(Endpoint.newBuilder().serviceName("app").build()).putTag("environment", "dev").putTag("http.method", "POST").putTag("http.path", "/users").timestamp(TODAY * 1000).build();
    storage.accept(asList(span1, span2, span3, span4)).execute();
    assertThat(storage.getKeys().execute()).containsOnlyOnce("http.path");
    assertThat(storage.getValues("http.path").execute()).containsOnlyOnce("/users");
}
Also used : Span(zipkin2.Span) Test(org.junit.Test)

Example 87 with Span

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

the class SpanNodeTest method build_headless.

@Test
public void build_headless() {
    Span s2 = Span.newBuilder().traceId("a").parentId("a").id("b").name("s2").build();
    Span s3 = Span.newBuilder().traceId("a").parentId("a").id("c").name("s3").build();
    Span s4 = Span.newBuilder().traceId("a").parentId("a").id("d").name("s4").build();
    SpanNode root = new SpanNode.Builder(logger).build(asList(s2, s3, s4));
    assertThat(root.span()).isNull();
    assertThat(root.children()).extracting(SpanNode::span).containsExactly(s2, s3, s4);
    assertThat(messages).containsExactly("building trace tree: traceId=000000000000000a", "substituting dummy node for missing root span: traceId=000000000000000a");
}
Also used : Span(zipkin2.Span) Test(org.junit.Test)

Example 88 with Span

use of zipkin2.proto3.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 89 with Span

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

the class SpanNodeTest method assertAncestry.

void assertAncestry(List<Span> trace) {
    SpanNode root = buildTree(trace);
    assertThat(root.span()).isEqualTo(trace.get(0));
    SpanNode current = root;
    for (int i = 1, length = trace.size() - 1; i < length; i++) {
        current = current.children.get(0);
        assertThat(current.span).isEqualTo(trace.get(i));
        assertThat(current.children).extracting(SpanNode::span).containsExactly(trace.get(i + 1));
    }
}
Also used : Endpoint(zipkin2.Endpoint)

Example 90 with Span

use of zipkin2.proto3.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)

Aggregations

Span (zipkin2.Span)290 Test (org.junit.Test)203 Test (org.junit.jupiter.api.Test)69 Endpoint (zipkin2.Endpoint)62 TestObjects.newClientSpan (zipkin2.TestObjects.newClientSpan)41 ArrayList (java.util.ArrayList)29 V1Span (zipkin2.v1.V1Span)23 List (java.util.List)19 Map (java.util.Map)18 Annotation (zipkin2.Annotation)13 AggregateCall (zipkin2.internal.AggregateCall)13 TraceSpan (com.google.devtools.cloudtrace.v1.TraceSpan)12 IOException (java.io.IOException)10 LinkedHashMap (java.util.LinkedHashMap)10 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)10 Arrays.asList (java.util.Arrays.asList)9 Span (com.google.devtools.cloudtrace.v2.Span)8 Trace (com.google.devtools.cloudtrace.v1.Trace)7 Call (zipkin2.Call)7 Span (zipkin2.proto3.Span)7