Search in sources :

Example 16 with Span

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

the class ITTracingServerInterceptor method serverParserTestWithStreamingResponse.

@Test
public void serverParserTestWithStreamingResponse() throws Exception {
    grpcTracing = grpcTracing.toBuilder().serverParser(new GrpcServerParser() {

        int responsesSent = 0;

        @Override
        protected <M> void onMessageSent(M message, SpanCustomizer span) {
            span.tag("grpc.message_sent." + responsesSent++, message.toString());
        }
    }).build();
    init();
    Iterator<HelloReply> replies = GreeterGrpc.newBlockingStub(client).sayHelloWithManyReplies(HELLO_REQUEST);
    assertThat(replies).hasSize(10);
    // all response messages are tagged to the same span
    Span span = spans.take();
    assertThat(span.tags()).hasSize(10);
}
Also used : HelloReply(io.grpc.examples.helloworld.HelloReply) SpanCustomizer(brave.SpanCustomizer) Span(zipkin2.Span) Test(org.junit.Test)

Example 17 with Span

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

the class ITTracingServerInterceptor method defaultSpanNameIsMethodName.

@Test
public void defaultSpanNameIsMethodName() throws Exception {
    GreeterGrpc.newBlockingStub(client).sayHello(HELLO_REQUEST);
    Span span = spans.take();
    assertThat(span.name()).isEqualTo("helloworld.greeter/sayhello");
}
Also used : Span(zipkin2.Span) Test(org.junit.Test)

Example 18 with Span

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

the class ITHttp method takeSpan.

/**
 * Call this to block until a span was reported
 */
protected Span takeSpan() throws InterruptedException {
    Span result = spans.take();
    assertThat(result.annotations()).extracting(Annotation::value).doesNotContain(CONTEXT_LEAK);
    return result;
}
Also used : Span(zipkin2.Span)

Example 19 with Span

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

the class ITHttpServer method httpPathTagExcludesQueryParams.

@Test
public void httpPathTagExcludesQueryParams() throws Exception {
    get("/foo?z=2&yAA=1");
    Span span = takeSpan();
    assertThat(span.tags()).containsEntry("http.path", "/foo");
}
Also used : Span(zipkin2.Span) Test(org.junit.Test)

Example 20 with Span

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

the class ITHttpServer method usesExistingTraceId.

@Test
public void usesExistingTraceId() throws Exception {
    String path = "/foo";
    final String traceId = "463ac35c9f6413ad";
    final String parentId = traceId;
    final String spanId = "48485a3953bb6124";
    get(new Request.Builder().url(url(path)).header("X-B3-TraceId", traceId).header("X-B3-ParentSpanId", parentId).header("X-B3-SpanId", spanId).header("X-B3-Sampled", "1").build());
    Span span = takeSpan();
    assertThat(span.traceId()).isEqualTo(traceId);
    assertThat(span.parentId()).isEqualTo(parentId);
    assertThat(span.id()).isEqualTo(spanId);
}
Also used : Request(okhttp3.Request) 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