Search in sources :

Example 31 with SERVER

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

the class MutableSpanTest method remoteEndpoint.

@Test
public void remoteEndpoint() {
    MutableSpan span = newSpan();
    Endpoint endpoint = Endpoint.newBuilder().serviceName("server").build();
    span.kind(CLIENT);
    span.remoteEndpoint(endpoint);
    span.start(1L);
    span.finish(2L);
    assertThat(span.toSpan().remoteEndpoint()).isEqualTo(endpoint);
}
Also used : Endpoint(zipkin2.Endpoint) Test(org.junit.Test)

Example 32 with SERVER

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

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

the class TraceTranslatorTest method testSinglehostClientRootSpan.

@Test
public void testSinglehostClientRootSpan() {
    Span span1 = Span.newBuilder().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().traceId("1").parentId("1").id("2").name("/a?server").timestamp(1474488796000000L).duration(5000000L).build();
    Span span3 = Span.newBuilder().traceId("1").parentId("2").id("3").name("/b?client").timestamp(// This is set because the client owns the span.
    1474488797000000L).duration(1500000L).build();
    Span span4 = Span.newBuilder().traceId("1").parentId("3").id("4").name("/b?server").timestamp(1474488797500000L).duration(800000L).build();
    Span span5 = Span.newBuilder().traceId("1").parentId("4").id("5").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)

Example 34 with SERVER

use of zipkin2.Span.Kind.SERVER 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)

Example 35 with SERVER

use of zipkin2.Span.Kind.SERVER in project spring-cloud-gcp by spring-cloud.

the class StackdriverTraceReporterTests method testSingleServerSpan.

@Test
public void testSingleServerSpan() {
    Span parent = Span.newBuilder().traceId("123").id("9999").name("http:parent").timestamp(beginTime).duration(endTime - beginTime).kind(Span.Kind.SERVER).build();
    this.reporter.report(parent);
    Assert.assertEquals(1, this.test.traceSpans.size());
    TraceSpan traceSpan = this.test.traceSpans.get(0);
    Assert.assertEquals("http:parent", traceSpan.getName());
    // Server Spans should use Span begin and end time, not SR or SS
    Assert.assertEquals(this.spanTranslator.createTimestamp(beginTime), traceSpan.getStartTime());
    Assert.assertEquals(this.spanTranslator.createTimestamp(endTime), traceSpan.getEndTime());
    Assert.assertEquals(TraceSpan.SpanKind.RPC_SERVER, traceSpan.getKind());
}
Also used : TraceSpan(com.google.devtools.cloudtrace.v1.TraceSpan) Span(zipkin2.Span) TraceSpan(com.google.devtools.cloudtrace.v1.TraceSpan) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

Span (zipkin2.Span)36 Test (org.junit.Test)31 Endpoint (zipkin2.Endpoint)17 Test (org.junit.jupiter.api.Test)9 TraceSpan (com.google.devtools.cloudtrace.v1.TraceSpan)7 Trace (com.google.devtools.cloudtrace.v1.Trace)5 NoopHealthCheckManager (com.wavefront.agent.channel.NoopHealthCheckManager)5 SpanSampler (com.wavefront.agent.sampler.SpanSampler)5 ByteBuf (io.netty.buffer.ByteBuf)5 ChannelHandlerContext (io.netty.channel.ChannelHandlerContext)5 DefaultFullHttpRequest (io.netty.handler.codec.http.DefaultFullHttpRequest)5 FullHttpRequest (io.netty.handler.codec.http.FullHttpRequest)5 Span (wavefront.report.Span)5 Task (io.crnk.monitor.brave.mock.models.Task)4 TestObjects.newClientSpan (zipkin2.TestObjects.newClientSpan)4 SpanBytesEncoder (zipkin2.codec.SpanBytesEncoder)4 RateSampler (com.wavefront.sdk.entities.tracing.sampling.RateSampler)3 Annotation (wavefront.report.Annotation)3 ElasticsearchStorage (zipkin2.elasticsearch.ElasticsearchStorage)3 V1Span (zipkin2.v1.V1Span)3