Search in sources :

Example 1 with OpenTracingClientFeature

use of org.apache.cxf.tracing.opentracing.OpenTracingClientFeature in project cxf by apache.

the class OpenTracingTracingTest method testThatProvidedSpanIsNotClosedWhenActive.

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

        @Override
        public void configure(final JaxWsProxyFactoryBean factory) {
            factory.getFeatures().add(new OpenTracingClientFeature(tracer));
        }
    });
    try (ActiveSpan scope = tracer.buildSpan("test span").startActive()) {
        assertThat(service.getBooks().size(), equalTo(2));
        assertThat(tracer.activeSpan(), not(nullValue()));
        assertThat(TestSender.getAllSpans().size(), equalTo(3));
        assertThat(TestSender.getAllSpans().get(0).getOperationName(), equalTo("Get Books"));
        assertThat(TestSender.getAllSpans().get(0).getReferences(), not(empty()));
        assertThat(TestSender.getAllSpans().get(1).getOperationName(), equalTo("POST /BookStore"));
        assertThat(TestSender.getAllSpans().get(1).getReferences(), not(empty()));
        assertThat(TestSender.getAllSpans().get(2).getOperationName(), equalTo("POST http://localhost:" + PORT + "/BookStore"));
        assertThat(TestSender.getAllSpans().get(2).getReferences(), not(empty()));
    }
    // Await till flush happens, usually every second
    await().atMost(Duration.ONE_SECOND).until(() -> TestSender.getAllSpans().size() == 4);
    assertThat(TestSender.getAllSpans().size(), equalTo(4));
    assertThat(TestSender.getAllSpans().get(3).getOperationName(), equalTo("test span"));
    assertThat(TestSender.getAllSpans().get(3).getReferences(), empty());
}
Also used : OpenTracingClientFeature(org.apache.cxf.tracing.opentracing.OpenTracingClientFeature) ActiveSpan(io.opentracing.ActiveSpan) BookStoreService(org.apache.cxf.systest.jaxws.tracing.BookStoreService) JaxWsProxyFactoryBean(org.apache.cxf.jaxws.JaxWsProxyFactoryBean) Test(org.junit.Test)

Example 2 with OpenTracingClientFeature

use of org.apache.cxf.tracing.opentracing.OpenTracingClientFeature in project cxf by apache.

the class OpenTracingTracingTest method testThatNewChildSpanIsCreatedWhenParentIsProvidedInCaseOfFault.

@Test
public void testThatNewChildSpanIsCreatedWhenParentIsProvidedInCaseOfFault() throws MalformedURLException {
    final BookStoreService service = createJaxWsService(new Configurator() {

        @Override
        public void configure(final JaxWsProxyFactoryBean factory) {
            factory.getFeatures().add(new OpenTracingClientFeature(tracer));
            factory.getOutInterceptors().add(new LoggingOutInterceptor());
            factory.getInInterceptors().add(new LoggingInInterceptor());
        }
    });
    try {
        service.removeBooks();
        fail("Expected SOAPFaultException to be raised");
    } catch (final SOAPFaultException ex) {
    /* expected exception */
    }
    assertThat(TestSender.getAllSpans().size(), equalTo(2));
    assertThat(TestSender.getAllSpans().get(0).getOperationName(), equalTo("POST /BookStore"));
    assertThat(TestSender.getAllSpans().get(1).getOperationName(), equalTo("POST http://localhost:" + PORT + "/BookStore"));
}
Also used : OpenTracingClientFeature(org.apache.cxf.tracing.opentracing.OpenTracingClientFeature) LoggingOutInterceptor(org.apache.cxf.ext.logging.LoggingOutInterceptor) BookStoreService(org.apache.cxf.systest.jaxws.tracing.BookStoreService) JaxWsProxyFactoryBean(org.apache.cxf.jaxws.JaxWsProxyFactoryBean) LoggingInInterceptor(org.apache.cxf.ext.logging.LoggingInInterceptor) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) Test(org.junit.Test)

Example 3 with OpenTracingClientFeature

use of org.apache.cxf.tracing.opentracing.OpenTracingClientFeature in project cxf by apache.

the class OpenTracingTracingTest method testThatNewChildSpanIsCreatedWhenParentIsProvided.

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

        @Override
        public void configure(final JaxWsProxyFactoryBean factory) {
            factory.getFeatures().add(new OpenTracingClientFeature(tracer));
        }
    });
    assertThat(service.getBooks().size(), equalTo(2));
    assertThat(TestSender.getAllSpans().size(), equalTo(3));
    assertThat(TestSender.getAllSpans().get(0).getOperationName(), equalTo("Get Books"));
    assertThat(TestSender.getAllSpans().get(0).getReferences(), not(empty()));
    assertThat(TestSender.getAllSpans().get(1).getOperationName(), equalTo("POST /BookStore"));
    assertThat(TestSender.getAllSpans().get(2).getOperationName(), equalTo("POST http://localhost:" + PORT + "/BookStore"));
}
Also used : OpenTracingClientFeature(org.apache.cxf.tracing.opentracing.OpenTracingClientFeature) BookStoreService(org.apache.cxf.systest.jaxws.tracing.BookStoreService) JaxWsProxyFactoryBean(org.apache.cxf.jaxws.JaxWsProxyFactoryBean) Test(org.junit.Test)

Aggregations

JaxWsProxyFactoryBean (org.apache.cxf.jaxws.JaxWsProxyFactoryBean)3 BookStoreService (org.apache.cxf.systest.jaxws.tracing.BookStoreService)3 OpenTracingClientFeature (org.apache.cxf.tracing.opentracing.OpenTracingClientFeature)3 Test (org.junit.Test)3 ActiveSpan (io.opentracing.ActiveSpan)1 SOAPFaultException (javax.xml.ws.soap.SOAPFaultException)1 LoggingInInterceptor (org.apache.cxf.ext.logging.LoggingInInterceptor)1 LoggingOutInterceptor (org.apache.cxf.ext.logging.LoggingOutInterceptor)1