Search in sources :

Example 1 with HTraceClientStartInterceptor

use of org.apache.cxf.tracing.htrace.HTraceClientStartInterceptor in project cxf by apache.

the class HTraceTracingTest method testThatNewChildSpanIsCreatedWhenParentIsProvided.

@Test
public void testThatNewChildSpanIsCreatedWhenParentIsProvided() throws MalformedURLException {
    final Tracer tracer = createTracer();
    final BookStoreService service = createJaxWsService(new Configurator() {

        @Override
        public void configure(final JaxWsProxyFactoryBean factory) {
            factory.getOutInterceptors().add(new HTraceClientStartInterceptor(tracer));
            factory.getInInterceptors().add(new HTraceClientStopInterceptor());
        }
    });
    assertThat(service.getBooks().size(), equalTo(2));
    assertThat(TestSpanReceiver.getAllSpans().size(), equalTo(3));
    assertThat(TestSpanReceiver.getAllSpans().get(0).getDescription(), equalTo("Get Books"));
    assertThat(TestSpanReceiver.getAllSpans().get(0).getParents().length, equalTo(1));
    assertThat(TestSpanReceiver.getAllSpans().get(1).getDescription(), equalTo("POST /BookStore"));
    assertThat(TestSpanReceiver.getAllSpans().get(2).getDescription(), equalTo("POST http://localhost:" + PORT + "/BookStore"));
    final Map<String, List<String>> response = getResponseHeaders(service);
    assertThat(response.get(TracerHeaders.DEFAULT_HEADER_SPAN_ID), not(nullValue()));
}
Also used : HTraceClientStopInterceptor(org.apache.cxf.tracing.htrace.HTraceClientStopInterceptor) Tracer(org.apache.htrace.core.Tracer) HTraceClientStartInterceptor(org.apache.cxf.tracing.htrace.HTraceClientStartInterceptor) BookStoreService(org.apache.cxf.systest.jaxws.tracing.BookStoreService) JaxWsProxyFactoryBean(org.apache.cxf.jaxws.JaxWsProxyFactoryBean) List(java.util.List) Test(org.junit.Test)

Example 2 with HTraceClientStartInterceptor

use of org.apache.cxf.tracing.htrace.HTraceClientStartInterceptor in project cxf by apache.

the class HTraceTracingTest method testThatProvidedSpanIsNotClosedWhenActive.

@Test
public void testThatProvidedSpanIsNotClosedWhenActive() throws MalformedURLException {
    final Tracer tracer = createTracer();
    final BookStoreService service = createJaxWsService(new Configurator() {

        @Override
        public void configure(final JaxWsProxyFactoryBean factory) {
            factory.getOutInterceptors().add(new HTraceClientStartInterceptor(tracer));
            factory.getInInterceptors().add(new HTraceClientStopInterceptor());
        }
    });
    try (TraceScope scope = tracer.newScope("test span")) {
        assertThat(service.getBooks().size(), equalTo(2));
        assertThat(Tracer.getCurrentSpan(), not(nullValue()));
        assertThat(TestSpanReceiver.getAllSpans().size(), equalTo(2));
        assertThat(TestSpanReceiver.getAllSpans().get(0).getDescription(), equalTo("Get Books"));
        assertThat(TestSpanReceiver.getAllSpans().get(0).getParents().length, equalTo(1));
        assertThat(TestSpanReceiver.getAllSpans().get(1).getDescription(), equalTo("POST /BookStore"));
    }
    assertThat(TestSpanReceiver.getAllSpans().size(), equalTo(3));
    assertThat(TestSpanReceiver.getAllSpans().get(2).getDescription(), equalTo("test span"));
    final Map<String, List<String>> response = getResponseHeaders(service);
    assertThat(response.get(TracerHeaders.DEFAULT_HEADER_SPAN_ID), not(nullValue()));
}
Also used : HTraceClientStopInterceptor(org.apache.cxf.tracing.htrace.HTraceClientStopInterceptor) Tracer(org.apache.htrace.core.Tracer) HTraceClientStartInterceptor(org.apache.cxf.tracing.htrace.HTraceClientStartInterceptor) BookStoreService(org.apache.cxf.systest.jaxws.tracing.BookStoreService) JaxWsProxyFactoryBean(org.apache.cxf.jaxws.JaxWsProxyFactoryBean) TraceScope(org.apache.htrace.core.TraceScope) List(java.util.List) Test(org.junit.Test)

Aggregations

List (java.util.List)2 JaxWsProxyFactoryBean (org.apache.cxf.jaxws.JaxWsProxyFactoryBean)2 BookStoreService (org.apache.cxf.systest.jaxws.tracing.BookStoreService)2 HTraceClientStartInterceptor (org.apache.cxf.tracing.htrace.HTraceClientStartInterceptor)2 HTraceClientStopInterceptor (org.apache.cxf.tracing.htrace.HTraceClientStopInterceptor)2 Tracer (org.apache.htrace.core.Tracer)2 Test (org.junit.Test)2 TraceScope (org.apache.htrace.core.TraceScope)1