Search in sources :

Example 36 with SERVER

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

the class StackdriverTraceReporterTests method testClientServerSpans.

@Test
public void testClientServerSpans() {
    Span clientSpan = Span.newBuilder().traceId("123").id("9999").name("http:call").timestamp(beginTime).duration(endTime - beginTime).kind(Span.Kind.CLIENT).build();
    Span serverSpan = Span.newBuilder().traceId("123").parentId(clientSpan.id()).id(clientSpan.id()).name("http:service").timestamp(beginTime).duration(endTime - beginTime).kind(Span.Kind.SERVER).build();
    this.reporter.report(serverSpan);
    this.reporter.report(clientSpan);
    Assert.assertEquals(2, this.test.traceSpans.size());
    TraceSpan serverTraceSpan = this.test.traceSpans.get(0);
    Assert.assertEquals("http:service", serverTraceSpan.getName());
    Assert.assertEquals(TraceSpan.SpanKind.RPC_SERVER, serverTraceSpan.getKind());
    TraceSpan clientTraceSpan = this.test.traceSpans.get(1);
    Assert.assertEquals("http:call", clientTraceSpan.getName());
    // Client span chould use CS and CR time, not Span begin or end time.
    Assert.assertEquals(this.spanTranslator.createTimestamp(beginTime), clientTraceSpan.getStartTime());
    Assert.assertEquals(this.spanTranslator.createTimestamp(endTime), clientTraceSpan.getEndTime());
    Assert.assertEquals(TraceSpan.SpanKind.RPC_CLIENT, clientTraceSpan.getKind());
    Assert.assertEquals(0, clientTraceSpan.getParentSpanId());
    Assert.assertNotEquals(Long.valueOf(serverSpan.parentId()).longValue(), serverTraceSpan.getParentSpanId());
    // Even though the client and server spans shared the same Span ID. In Stackdriver Trace,
    // the IDs should be different. This is accomplished through
    // StackdriverTraceSpanListener.rewriteIds().
    Assert.assertNotEquals(clientTraceSpan.getSpanId(), serverTraceSpan.getSpanId());
    // Although the Span IDs were re-written, the server Span's parent ID should still refer
    // to client Span ID.
    Assert.assertEquals(serverTraceSpan.getParentSpanId(), clientTraceSpan.getSpanId());
}
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)

Example 37 with SERVER

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

the class ITZipkinSelfTracing method postSpan.

/**
 * This POSTs a single span. Afterwards, we expect this trace in storage, and also the self-trace
 * of POSTing it.
 */
void postSpan(String version) throws IOException {
    SpanBytesEncoder encoder = "v1".equals(version) ? SpanBytesEncoder.JSON_V1 : SpanBytesEncoder.JSON_V2;
    List<Span> testTrace = Collections.singletonList(Span.newBuilder().timestamp(TODAY).traceId("1").id("2").name("test-trace").build());
    Response response = client.newCall(new Request.Builder().url(url(server, "/api/" + version + "/spans")).post(RequestBody.create(encoder.encodeList(testTrace))).build()).execute();
    assertSuccessful(response);
}
Also used : Response(okhttp3.Response) SpanBytesEncoder(zipkin2.codec.SpanBytesEncoder) QueryRequest(zipkin2.storage.QueryRequest) Request(okhttp3.Request) Span(zipkin2.Span)

Example 38 with SERVER

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

the class ITElasticsearchHealthCheck method healthyThenNotHealthyThenHealthy.

// If this flakes, uncomment in initWithHosts and log4j2.properties
@Test
public void healthyThenNotHealthyThenHealthy() {
    try (ElasticsearchStorage storage = context.getBean(ElasticsearchStorage.class)) {
        assertOk(storage.check());
        logger.info("setting server 1 and 2 unhealthy");
        server1Health.setHealthy(false);
        server2Health.setHealthy(false);
        awaitTimeout.untilAsserted(() -> assertThat(storage.check().ok()).isFalse());
        logger.info("setting server 1 healthy");
        server1Health.setHealthy(true);
        awaitTimeout.untilAsserted(() -> assertThat(storage.check().ok()).isTrue());
    }
}
Also used : ElasticsearchStorage(zipkin2.elasticsearch.ElasticsearchStorage) Test(org.junit.Test)

Example 39 with SERVER

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

the class ITTraces method getTrace_differentiatesDebugFromShared.

/**
 * Prevents subtle bugs which can result in mixed-length traces from linking.
 */
@Test
protected void getTrace_differentiatesDebugFromShared(TestInfo testInfo) throws Exception {
    String testSuffix = testSuffix(testInfo);
    Span clientSpan = newClientSpan(testSuffix).toBuilder().debug(true).build();
    Span serverSpan = clientSpan.toBuilder().kind(SERVER).debug(null).shared(true).build();
    accept(clientSpan, serverSpan);
    // assertGetTraceReturns does recursive comparison
    assertGetTraceReturns(clientSpan.traceId(), asList(clientSpan, serverSpan));
}
Also used : TestObjects.newClientSpan(zipkin2.TestObjects.newClientSpan) Span(zipkin2.Span) Test(org.junit.jupiter.api.Test)

Example 40 with SERVER

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

the class ITTraces method getTraces_differentiatesDebugFromShared.

/**
 * Prevents subtle bugs which can result in mixed-length traces from linking.
 */
@Test
protected void getTraces_differentiatesDebugFromShared(TestInfo testInfo) throws Exception {
    String testSuffix = testSuffix(testInfo);
    Span clientSpan = newClientSpan(testSuffix).toBuilder().debug(true).build();
    Span serverSpan = clientSpan.toBuilder().kind(SERVER).debug(null).shared(true).build();
    accept(clientSpan, serverSpan);
    // assertGetTracesReturns does recursive comparison
    assertGetTracesReturns(asList(clientSpan.traceId()), asList(clientSpan, serverSpan));
}
Also used : TestObjects.newClientSpan(zipkin2.TestObjects.newClientSpan) Span(zipkin2.Span) Test(org.junit.jupiter.api.Test)

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