Search in sources :

Example 6 with Span

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

the class ITTracingFilter_Consumer method onTransportException_addsErrorTag_async.

@Test
public void onTransportException_addsErrorTag_async() throws Exception {
    server.stop();
    RpcContext.getContext().asyncCall(() -> client.get().sayHello("romeo"));
    Span span = spans.take();
    assertThat(span.tags().get("error")).contains("RemotingException");
}
Also used : Span(zipkin2.Span) Test(org.junit.Test)

Example 7 with Span

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

the class ITTracingFilter_Provider method usesExistingTraceId.

@Test
public void usesExistingTraceId() throws Exception {
    final String traceId = "463ac35c9f6413ad";
    final String parentId = traceId;
    final String spanId = "48485a3953bb6124";
    RpcContext.getContext().getAttachments().put("X-B3-TraceId", traceId);
    RpcContext.getContext().getAttachments().put("X-B3-ParentSpanId", parentId);
    RpcContext.getContext().getAttachments().put("X-B3-SpanId", spanId);
    RpcContext.getContext().getAttachments().put("X-B3-Sampled", "1");
    client.get().sayHello("jorge");
    Span span = spans.take();
    assertThat(span.traceId()).isEqualTo(traceId);
    assertThat(span.parentId()).isEqualTo(parentId);
    assertThat(span.id()).isEqualTo(spanId);
    assertThat(span.shared()).isTrue();
}
Also used : Span(zipkin2.Span) Test(org.junit.Test)

Example 8 with Span

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

the class ITTracingFilter_Provider method defaultSpanNameIsMethodName.

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

Example 9 with Span

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

the class ITTracingClientInterceptor method clientParserTest.

@Test
public void clientParserTest() throws Exception {
    closeClient(client);
    tracing = tracing.toBuilder().clientParser(new GrpcClientParser() {

        @Override
        protected <M> void onMessageSent(M message, SpanCustomizer span) {
            span.tag("grpc.message_sent", message.toString());
            if (tracing.tracing().currentTraceContext().get() != null) {
                span.tag("grpc.message_sent.visible", "true");
            }
        }

        @Override
        protected <M> void onMessageReceived(M message, SpanCustomizer span) {
            span.tag("grpc.message_received", message.toString());
            if (tracing.tracing().currentTraceContext().get() != null) {
                span.tag("grpc.message_received.visible", "true");
            }
        }

        @Override
        protected <ReqT, RespT> String spanName(MethodDescriptor<ReqT, RespT> methodDescriptor) {
            return methodDescriptor.getType().name();
        }
    }).build();
    client = newClient();
    GreeterGrpc.newBlockingStub(client).sayHello(HELLO_REQUEST);
    Span span = spans.take();
    assertThat(span.name()).isEqualTo("unary");
    assertThat(span.tags()).containsKeys("grpc.message_received", "grpc.message_sent", "grpc.message_received.visible", "grpc.message_sent.visible");
}
Also used : SpanCustomizer(brave.SpanCustomizer) Span(zipkin2.Span) Test(org.junit.Test)

Example 10 with Span

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

the class ITTracingClientInterceptor 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)

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