Search in sources :

Example 16 with Span

use of io.opencensus.proto.trace.v1.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 io.opencensus.proto.trace.v1.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 io.opencensus.proto.trace.v1.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 io.opencensus.proto.trace.v1.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 io.opencensus.proto.trace.v1.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)192 Test (org.junit.jupiter.api.Test)67 TestObjects.newClientSpan (zipkin2.TestObjects.newClientSpan)41 Endpoint (zipkin2.Endpoint)37 ArrayList (java.util.ArrayList)24 V1Span (zipkin2.v1.V1Span)17 List (java.util.List)14 AggregateCall (zipkin2.internal.AggregateCall)13 TraceSpan (com.google.devtools.cloudtrace.v1.TraceSpan)12 Arrays.asList (java.util.Arrays.asList)9 Map (java.util.Map)9 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)9 Span (com.google.devtools.cloudtrace.v2.Span)8 LinkedHashMap (java.util.LinkedHashMap)8 Trace (com.google.devtools.cloudtrace.v1.Trace)7 Span (zipkin2.proto3.Span)7 SpanData (io.opencensus.trace.export.SpanData)6 SpanCustomizer (brave.SpanCustomizer)5 IOException (java.io.IOException)5