Search in sources :

Example 26 with MockTracer

use of io.opentracing.mock.MockTracer in project wildfly-swarm by wildfly-swarm.

the class SkipPatternTest method noSpansForServletSpansMatchingSkipPattern.

@Test
public void noSpansForServletSpansMatchingSkipPattern() throws IOException {
    MockTracer tracer = MockTracerResolver.TRACER_INSTANCE;
    assertEquals(0, tracer.finishedSpans().size());
    hitEndpoint("http://localhost:8080/_opentracing/hello");
    assertEquals(2, tracer.finishedSpans().size());
    // no new *servlet* spans are to be created for this, but business spans are still created
    hitEndpoint("http://localhost:8080/_opentracing/health");
    assertEquals(3, tracer.finishedSpans().size());
}
Also used : MockTracer(io.opentracing.mock.MockTracer) Test(org.junit.Test)

Example 27 with MockTracer

use of io.opentracing.mock.MockTracer in project wildfly-swarm by wildfly-swarm.

the class TraceResolverOnDeploymentTest method testAsyncEndpoint.

@Test
public void testAsyncEndpoint() throws IOException {
    MockTracer tracer = MockTracerResolver.TRACER_INSTANCE;
    assertEquals(0, tracer.finishedSpans().size());
    hitEndpoint("http://localhost:8080/_opentracing/async");
    assertEquals(1, tracer.finishedSpans().size());
}
Also used : MockTracer(io.opentracing.mock.MockTracer) Test(org.junit.Test)

Example 28 with MockTracer

use of io.opentracing.mock.MockTracer in project wildfly-swarm by wildfly-swarm.

the class TraceResolverOnDeploymentTest method testOneSpanIsReportedPerRequest.

@Test
public void testOneSpanIsReportedPerRequest() throws IOException {
    MockTracer tracer = MockTracerResolver.TRACER_INSTANCE;
    assertEquals(0, tracer.finishedSpans().size());
    hitEndpoint("http://localhost:8080/_opentracing/hello");
    assertEquals(2, tracer.finishedSpans().size());
}
Also used : MockTracer(io.opentracing.mock.MockTracer) Test(org.junit.Test)

Example 29 with MockTracer

use of io.opentracing.mock.MockTracer in project batfish by batfish.

the class WorkItemTest method initTracer.

@BeforeClass
public static void initTracer() {
    _mockTracer = new MockTracer(new ThreadLocalActiveSpanSource(), Propagator.TEXT_MAP);
    _noopTracer = NoopTracerFactory.create();
}
Also used : MockTracer(io.opentracing.mock.MockTracer) ThreadLocalActiveSpanSource(io.opentracing.util.ThreadLocalActiveSpanSource) BeforeClass(org.junit.BeforeClass)

Example 30 with MockTracer

use of io.opentracing.mock.MockTracer in project motan by weibocom.

the class OpenTracingFilterTest method setUp.

@Before
public void setUp() throws Exception {
    OTFilter = new OpenTracingFilter();
    tracer = new MockTracer();
    OpenTracingContext.tracerFactory = new TracerFactory() {

        @Override
        public Tracer getTracer() {
            return tracer;
        }
    };
    URL url = new URL("motan", "localhost", 8002, "HelloService");
    request = new DefaultRequest();
    request.setInterfaceName("HelloService");
    request.setAttachment(URLParamType.group.name(), "test");
    request.setMethodName("sayHello");
    request.setParamtersDesc("java.lang.String");
    response = new DefaultResponse();
    refer = new AbstractReferer<HelloService>(HelloService.class, url) {

        @Override
        public void destroy() {
        }

        @Override
        public boolean isAvailable() {
            return true;
        }

        @Override
        protected Response doCall(Request request) {
            return response;
        }

        @Override
        protected boolean doInit() {
            return true;
        }
    };
    provider = new DefaultProvider<HelloService>(new HelloServiceImpl(), url, HelloService.class) {

        @Override
        public Response call(Request request) {
            return response;
        }
    };
}
Also used : DefaultResponse(com.weibo.api.motan.rpc.DefaultResponse) DefaultRequest(com.weibo.api.motan.rpc.DefaultRequest) Tracer(io.opentracing.Tracer) MockTracer(io.opentracing.mock.MockTracer) Request(com.weibo.api.motan.rpc.Request) DefaultRequest(com.weibo.api.motan.rpc.DefaultRequest) MockTracer(io.opentracing.mock.MockTracer) URL(com.weibo.api.motan.rpc.URL) DefaultResponse(com.weibo.api.motan.rpc.DefaultResponse) Response(com.weibo.api.motan.rpc.Response) Before(org.junit.Before)

Aggregations

MockTracer (io.opentracing.mock.MockTracer)31 Test (org.junit.Test)23 MockSpan (io.opentracing.mock.MockSpan)17 SpanDecorator (org.apache.camel.opentracing.SpanDecorator)13 Endpoint (org.apache.camel.Endpoint)11 Exchange (org.apache.camel.Exchange)10 Message (org.apache.camel.Message)8 DefaultResponse (com.weibo.api.motan.rpc.DefaultResponse)2 Response (com.weibo.api.motan.rpc.Response)2 Before (org.junit.Before)2 DefaultRequest (com.weibo.api.motan.rpc.DefaultRequest)1 Request (com.weibo.api.motan.rpc.Request)1 URL (com.weibo.api.motan.rpc.URL)1 Scope (io.opentracing.Scope)1 Tracer (io.opentracing.Tracer)1 ThreadLocalActiveSpanSource (io.opentracing.util.ThreadLocalActiveSpanSource)1 ThreadLocalScopeManager (io.opentracing.util.ThreadLocalScopeManager)1 Client (javax.ws.rs.client.Client)1 WebTarget (javax.ws.rs.client.WebTarget)1 Response (javax.ws.rs.core.Response)1