Search in sources :

Example 6 with ScopedSpan

use of brave.ScopedSpan in project brave by openzipkin.

the class ITTracingStatementInterceptor method makesChildOfCurrentSpan.

@Test
public void makesChildOfCurrentSpan() throws Exception {
    ScopedSpan parent = tracing.tracer().startScopedSpan("test");
    try {
        prepareExecuteSelect(QUERY);
    } finally {
        parent.finish();
    }
    assertThat(spans).hasSize(2);
}
Also used : ScopedSpan(brave.ScopedSpan) Test(org.junit.Test)

Example 7 with ScopedSpan

use of brave.ScopedSpan in project brave by openzipkin.

the class ITTracingP6Factory method makesChildOfCurrentSpan.

@Test
public void makesChildOfCurrentSpan() throws Exception {
    ScopedSpan parent = tracing.tracer().startScopedSpan("test");
    try {
        prepareExecuteSelect(QUERY);
    } finally {
        parent.finish();
    }
    assertThat(spans).hasSize(2);
}
Also used : ScopedSpan(brave.ScopedSpan) Test(org.junit.Test)

Example 8 with ScopedSpan

use of brave.ScopedSpan in project cxf by apache.

the class CatalogServiceImpl method addBook.

public void addBook(Book book) {
    final TraceContext parent = brave.tracer().currentSpan().context();
    executor.submit(() -> {
        final ScopedSpan span = brave.tracer().startScopedSpanWithParent("Inserting New Book", parent);
        try {
            books.put(book.getId(), book);
        } finally {
            span.finish();
        }
    });
}
Also used : TraceContext(brave.propagation.TraceContext) ScopedSpan(brave.ScopedSpan)

Example 9 with ScopedSpan

use of brave.ScopedSpan in project brave by openzipkin.

the class BaseITTracingClientInterceptor method messageTagging_unary.

/**
 * This shows that a {@link ClientInterceptor} can see the server server span when processing the
 * request and response.
 */
@Test
public void messageTagging_unary() {
    initMessageTaggingClient();
    ScopedSpan span = tracing.tracer().startScopedSpan("parent");
    try {
        GreeterGrpc.newBlockingStub(client).sayHello(HELLO_REQUEST);
    } finally {
        span.finish();
    }
    assertThat(testSpanHandler.takeRemoteSpan(CLIENT).tags()).containsKey("grpc.message_send.1");
    // Response processing happens on the invocation (parent) trace context
    assertThat(testSpanHandler.takeLocalSpan().tags()).containsKey("grpc.message_recv.1");
}
Also used : ScopedSpan(brave.ScopedSpan) Test(org.junit.Test)

Example 10 with ScopedSpan

use of brave.ScopedSpan in project brave by openzipkin.

the class BaseITTracingClientInterceptor method clientParserTest.

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

        @Override
        protected <M> void onMessageSent(M message, SpanCustomizer span) {
            span.tag("grpc.message_sent", message.toString());
            if (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.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();
    ScopedSpan parent = tracing.tracer().startScopedSpan("parent");
    try {
        GreeterGrpc.newBlockingStub(client).sayHello(HELLO_REQUEST);
    } finally {
        parent.finish();
    }
    MutableSpan span = testSpanHandler.takeRemoteSpan(CLIENT);
    assertThat(span.name()).isEqualTo("UNARY");
    assertThat(span.tags()).containsKeys("grpc.message_received", "grpc.message_sent", "grpc.message_received.visible", "grpc.message_sent.visible");
    testSpanHandler.takeLocalSpan();
}
Also used : MutableSpan(brave.handler.MutableSpan) CurrentSpanCustomizer(brave.CurrentSpanCustomizer) SpanCustomizer(brave.SpanCustomizer) ScopedSpan(brave.ScopedSpan) Test(org.junit.Test)

Aggregations

ScopedSpan (brave.ScopedSpan)16 Test (org.junit.Test)14 MutableSpan (brave.handler.MutableSpan)3 Tracing (brave.Tracing)2 TraceContext (brave.propagation.TraceContext)2 BookRestClient (org.apache.cxf.systest.microprofile.rest.client.tracing.BookRestClient)2 CurrentSpanCustomizer (brave.CurrentSpanCustomizer)1 Span (brave.Span)1 CLIENT (brave.Span.Kind.CLIENT)1 SpanCustomizer (brave.SpanCustomizer)1 SpanHandler (brave.handler.SpanHandler)1 FromRequestAdapter (brave.http.HttpClientAdapters.FromRequestAdapter)1 IntegrationTestSpanHandler (brave.test.IntegrationTestSpanHandler)1 HelloReply (io.grpc.examples.helloworld.HelloReply)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 Assertions.assertThatThrownBy (org.assertj.core.api.Assertions.assertThatThrownBy)1 After (org.junit.After)1 Before (org.junit.Before)1 Rule (org.junit.Rule)1 RunWith (org.junit.runner.RunWith)1