Search in sources :

Example 46 with Kind

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

the class MutableSpanTest method finish.

private void finish(Kind braveKind, Span.Kind span2Kind) {
    MutableSpan span = newSpan();
    span.kind(braveKind);
    span.start(1L);
    span.finish(2L);
    Span span2 = span.toSpan();
    assertThat(span2.annotations()).isEmpty();
    assertThat(span2.timestamp()).isEqualTo(1L);
    assertThat(span2.duration()).isEqualTo(1L);
    assertThat(span2.kind()).isEqualTo(span2Kind);
}
Also used : Span(zipkin2.Span)

Example 47 with Kind

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

the class LabelExtractorTest method testEndpointIsSetIpv6.

@Test
public void testEndpointIsSetIpv6() {
    Endpoint.Builder serverEndpointBuilder = Endpoint.newBuilder().serviceName("service1").port(80);
    serverEndpointBuilder.parseIp("::1");
    Endpoint serverEndpoint = serverEndpointBuilder.build();
    Endpoint.Builder clientEndpointBuilder = Endpoint.newBuilder().serviceName("service2").port(80);
    clientEndpointBuilder.parseIp("::1");
    Endpoint clientEndpoint = clientEndpointBuilder.build();
    Span serverSpan = Span.newBuilder().kind(Kind.SERVER).traceId("4").name("test-span").id("5").localEndpoint(serverEndpoint).build();
    Span clientSpan = Span.newBuilder().kind(Kind.CLIENT).traceId("4").name("test-span").id("6").parentId("5").localEndpoint(clientEndpoint).build();
    String prefix = "test.prefix/";
    LabelExtractor extractor = new LabelExtractor(Collections.<String, String>emptyMap(), prefix);
    Map<String, String> serverLabels = extractor.extract(serverSpan);
    assertNull(serverLabels.get(prefix + "endpoint.ipv4"));
    assertEquals("::1", serverLabels.get(prefix + "endpoint.ipv6"));
    Map<String, String> clientLabels = extractor.extract(clientSpan);
    assertNull(clientLabels.get(prefix + "endpoint.ipv4"));
    assertNull(clientLabels.get(prefix + "endpoint.ipv6"));
}
Also used : Endpoint(zipkin2.Endpoint) Span(zipkin2.Span) Test(org.junit.Test)

Example 48 with Kind

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

the class LabelExtractorTest method testEndpointIsSetIpv4.

@Test
public void testEndpointIsSetIpv4() {
    Endpoint.Builder serverEndpointBuilder = Endpoint.newBuilder().serviceName("service1").port(80);
    serverEndpointBuilder.parseIp("10.0.0.1");
    Endpoint serverEndpoint = serverEndpointBuilder.build();
    Endpoint.Builder clientEndpointBuilder = Endpoint.newBuilder().serviceName("service2").port(80);
    clientEndpointBuilder.parseIp("10.0.0.1");
    Endpoint clientEndpoint = clientEndpointBuilder.build();
    Span serverSpan = Span.newBuilder().kind(Kind.SERVER).traceId("4").name("test-span").id("5").localEndpoint(serverEndpoint).build();
    Span clientSpan = Span.newBuilder().kind(Kind.CLIENT).traceId("4").name("test-span").id("6").parentId("5").localEndpoint(clientEndpoint).build();
    String prefix = "test.prefix/";
    LabelExtractor extractor = new LabelExtractor(Collections.<String, String>emptyMap(), prefix);
    Map<String, String> serverLabels = extractor.extract(serverSpan);
    assertEquals("10.0.0.1", serverLabels.get(prefix + "endpoint.ipv4"));
    assertNull(serverLabels.get(prefix + "endpoint.ipv6"));
    Map<String, String> clientLabels = extractor.extract(clientSpan);
    assertNull(clientLabels.get(prefix + "endpoint.ipv4"));
    assertNull(clientLabels.get(prefix + "endpoint.ipv6"));
}
Also used : Endpoint(zipkin2.Endpoint) Span(zipkin2.Span) Test(org.junit.Test)

Example 49 with Kind

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

the class TraceTranslatorTest method testMultihostClientRootSpan_noTimestamp.

@Test
public void testMultihostClientRootSpan_noTimestamp() {
    Span span1 = Span.newBuilder().kind(Kind.CLIENT).traceId("1").id("1").name("/a?client").build();
    Span span2 = Span.newBuilder().kind(Kind.SERVER).shared(true).traceId("1").id("1").name("/a?server").build();
    Span span3 = Span.newBuilder().kind(Kind.CLIENT).traceId("1").parentId("1").id("2").name("/b?client").build();
    Span span4 = Span.newBuilder().kind(Kind.SERVER).shared(true).traceId("1").parentId("1").id("2").name("/b?server").build();
    Span span5 = Span.newBuilder().traceId("1").parentId("2").id("3").name("custom-span").build();
    Collection<Trace> traces = TraceTranslator.translateSpans("test-project", Arrays.asList(span1, span2, span3, span4, span5));
    assertEquals(1, traces.size());
    Trace trace = traces.iterator().next();
    Map<String, TraceSpan> spansByName = getSpansByName(trace);
    assertThat(spansByName).containsOnlyKeys("/a?client", "/a?server", "/b?client", "/b?server", "custom-span");
    assertDistinctSpanIds(trace);
    assertThat(spansByName.get("custom-span").getParentSpanId()).isEqualTo(spansByName.get("/b?server").getSpanId());
    assertThat(spansByName.get("/b?server").getParentSpanId()).isEqualTo(spansByName.get("/b?client").getSpanId());
    assertThat(spansByName.get("/b?client").getParentSpanId()).isEqualTo(spansByName.get("/a?server").getSpanId());
    assertThat(spansByName.get("/a?server").getParentSpanId()).isEqualTo(spansByName.get("/a?client").getSpanId());
    assertThat(spansByName.get("/a?client").getParentSpanId()).isEqualTo(0);
}
Also used : Trace(com.google.devtools.cloudtrace.v1.Trace) TraceSpan(com.google.devtools.cloudtrace.v1.TraceSpan) Span(zipkin2.Span) TraceSpan(com.google.devtools.cloudtrace.v1.TraceSpan) Test(org.junit.Test)

Example 50 with Kind

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

the class TraceTranslatorTest method testMultihostClientRootSpan.

@Test
public void testMultihostClientRootSpan() {
    Span span1 = Span.newBuilder().kind(Kind.CLIENT).traceId("1").id("1").name("/a?client").timestamp(// This is set because the client owns the span
    1474488796000000L).duration(5000000L).build();
    Span span2 = Span.newBuilder().kind(Kind.SERVER).shared(true).traceId("1").id("1").name("/a?server").build();
    Span span3 = Span.newBuilder().kind(Kind.CLIENT).traceId("1").parentId("1").id("2").name("/b?client").timestamp(// This is set because the client owns the span.
    1474488797000000L).duration(1500000L).build();
    Span span4 = Span.newBuilder().kind(Kind.SERVER).shared(true).traceId("1").parentId("1").id("2").name("/b?server").build();
    Span span5 = Span.newBuilder().traceId("1").parentId("2").id("3").name("custom-span").timestamp(1474488797600000L).duration(200000L).build();
    Collection<Trace> traces = TraceTranslator.translateSpans("test-project", Arrays.asList(span1, span2, span3, span4, span5));
    assertEquals(1, traces.size());
    Trace trace = traces.iterator().next();
    Map<String, TraceSpan> spansByName = getSpansByName(trace);
    assertThat(spansByName).containsOnlyKeys("/a?client", "/a?server", "/b?client", "/b?server", "custom-span");
    assertDistinctSpanIds(trace);
    assertThat(spansByName.get("custom-span").getParentSpanId()).isEqualTo(spansByName.get("/b?server").getSpanId());
    assertThat(spansByName.get("/b?server").getParentSpanId()).isEqualTo(spansByName.get("/b?client").getSpanId());
    assertThat(spansByName.get("/b?client").getParentSpanId()).isEqualTo(spansByName.get("/a?server").getSpanId());
    assertThat(spansByName.get("/a?server").getParentSpanId()).isEqualTo(spansByName.get("/a?client").getSpanId());
    assertThat(spansByName.get("/a?client").getParentSpanId()).isEqualTo(0);
}
Also used : Trace(com.google.devtools.cloudtrace.v1.Trace) TraceSpan(com.google.devtools.cloudtrace.v1.TraceSpan) Span(zipkin2.Span) TraceSpan(com.google.devtools.cloudtrace.v1.TraceSpan) Test(org.junit.Test)

Aggregations

Span (zipkin2.Span)77 Test (org.junit.Test)54 Endpoint (zipkin2.Endpoint)28 Test (org.junit.jupiter.api.Test)17 V1Span (zipkin2.v1.V1Span)10 TraceSpan (com.google.devtools.cloudtrace.v1.TraceSpan)8 SpanSampler (com.wavefront.agent.sampler.SpanSampler)6 ByteBuf (io.netty.buffer.ByteBuf)6 ChannelHandlerContext (io.netty.channel.ChannelHandlerContext)6 FullHttpRequest (io.netty.handler.codec.http.FullHttpRequest)6 IOException (java.io.IOException)6 Map (java.util.Map)6 Span (wavefront.report.Span)6 NoopHealthCheckManager (com.wavefront.agent.channel.NoopHealthCheckManager)5 DefaultFullHttpRequest (io.netty.handler.codec.http.DefaultFullHttpRequest)5 TestObjects.newClientSpan (zipkin2.TestObjects.newClientSpan)5 Trace (com.google.devtools.cloudtrace.v1.Trace)4 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)4 Annotation (wavefront.report.Annotation)4 Annotation (zipkin2.Annotation)3