Search in sources :

Example 11 with ScopedSpan

use of brave.ScopedSpan in project brave by openzipkin.

the class DeprecatedHttpClientHandlerTest method handleSend_makesAChild.

@Test
public void handleSend_makesAChild() {
    ScopedSpan parent = httpTracing.tracing().tracer().startScopedSpan("test");
    try {
        assertThat(handler.handleSend(injector, request)).extracting(brave.Span::isNoop, s -> s.context().parentId()).containsExactly(false, parent.context().spanId());
    } finally {
        parent.finish();
    }
    spanHandler.takeLocalSpan();
}
Also used : ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) ArgumentMatchers.isNull(org.mockito.ArgumentMatchers.isNull) Tracing(brave.Tracing) IntegrationTestSpanHandler(brave.test.IntegrationTestSpanHandler) CLIENT(brave.Span.Kind.CLIENT) ScopedSpan(brave.ScopedSpan) Mock(org.mockito.Mock) ArgumentMatchers.eq(org.mockito.ArgumentMatchers.eq) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) RunWith(org.junit.runner.RunWith) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) TraceContext(brave.propagation.TraceContext) Mockito.verify(org.mockito.Mockito.verify) Rule(org.junit.Rule) Assertions.assertThatThrownBy(org.assertj.core.api.Assertions.assertThatThrownBy) FromRequestAdapter(brave.http.HttpClientAdapters.FromRequestAdapter) After(org.junit.After) Spy(org.mockito.Spy) MockitoJUnitRunner(org.mockito.junit.MockitoJUnitRunner) Before(org.junit.Before) Mockito.mock(org.mockito.Mockito.mock) ScopedSpan(brave.ScopedSpan) Test(org.junit.Test)

Example 12 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 13 with ScopedSpan

use of brave.ScopedSpan in project brave by openzipkin.

the class ITTracingQueryInterceptor 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 14 with ScopedSpan

use of brave.ScopedSpan in project brave by openzipkin.

the class TracingJdbcEventListenerTest method handleAfterExecute_without_beforeExecute_getting_called.

@Test
public void handleAfterExecute_without_beforeExecute_getting_called() {
    ScopedSpan parent = tracing.tracer().startScopedSpan("test");
    try {
        TracingJdbcEventListener listener = new TracingJdbcEventListener("", false, logOptions);
        listener.onAfterAnyExecute(statementInformation, 1, null);
        listener.onAfterAnyExecute(statementInformation, 1, null);
    } finally {
        parent.finish();
    }
}
Also used : ScopedSpan(brave.ScopedSpan) Test(org.junit.Test)

Example 15 with ScopedSpan

use of brave.ScopedSpan in project brave by openzipkin.

the class SkeletalSpansTest method acceptTwoServerRequests.

/**
 * Simulates some service calls
 */
static void acceptTwoServerRequests(Tracer server1Tracer, Tracer server2Tracer) {
    Span server1 = server1Tracer.newTrace().name("get").kind(Kind.SERVER).start();
    Span server2 = server1Tracer.newTrace().name("get").kind(Kind.SERVER).start();
    try {
        Span client1 = server1Tracer.newChild(server1.context()).name("post").kind(Kind.CLIENT).start();
        server2Tracer.joinSpan(fakeUseOfHeaders(client1.context())).name("post").kind(Kind.SERVER).start().finish();
        ScopedSpan local1 = server1Tracer.startScopedSpanWithParent("controller", server1.context());
        try {
            try {
                server1Tracer.newTrace().name("async1").start().finish();
                server2Tracer.newTrace().name("async2").start().finish();
                ScopedSpan local2 = server1Tracer.startScopedSpanWithParent("controller2", server2.context());
                Span client2 = server1Tracer.nextSpan().name("post").kind(Kind.CLIENT).start();
                try {
                    server2Tracer.joinSpan(fakeUseOfHeaders(client2.context())).name("post").kind(Kind.SERVER).start().error(new RuntimeException()).finish();
                    server1Tracer.nextSpan().name("post").kind(Kind.CLIENT).start().remoteServiceName("uninstrumentedServer").error(new RuntimeException()).finish();
                } finally {
                    client2.finish();
                    local2.finish();
                }
            } finally {
                server2.finish();
            }
        } finally {
            client1.finish();
            local1.finish();
        }
    } finally {
        server1.finish();
    }
}
Also used : ScopedSpan(brave.ScopedSpan) Span(brave.Span) MutableSpan(brave.handler.MutableSpan) ScopedSpan(brave.ScopedSpan)

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