Search in sources :

Example 16 with BookStoreService

use of org.apache.cxf.systest.jaxws.tracing.BookStoreService in project cxf by apache.

the class OpenTracingTracingTest method testThatNewInnerSpanIsCreated.

@Test
public void testThatNewInnerSpanIsCreated() throws MalformedURLException {
    final SpanContext spanId = fromRandom();
    final Map<String, List<String>> headers = new HashMap<>();
    tracer.inject(spanId, Builtin.HTTP_HEADERS, new TextMapInjectAdapter(headers));
    final BookStoreService service = createJaxWsService(headers);
    assertThat(service.getBooks().size(), equalTo(2));
    assertThat(TestSender.getAllSpans().size(), equalTo(2));
    assertThat(TestSender.getAllSpans().get(0).getOperationName(), equalTo("Get Books"));
    assertThat(TestSender.getAllSpans().get(1).getOperationName(), equalTo("POST /BookStore"));
}
Also used : SpanContext(com.uber.jaeger.SpanContext) HashMap(java.util.HashMap) TextMapInjectAdapter(org.apache.cxf.tracing.opentracing.internal.TextMapInjectAdapter) BookStoreService(org.apache.cxf.systest.jaxws.tracing.BookStoreService) List(java.util.List) Test(org.junit.Test)

Example 17 with BookStoreService

use of org.apache.cxf.systest.jaxws.tracing.BookStoreService 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 18 with BookStoreService

use of org.apache.cxf.systest.jaxws.tracing.BookStoreService 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)

Example 19 with BookStoreService

use of org.apache.cxf.systest.jaxws.tracing.BookStoreService in project cxf by apache.

the class OpenTracingTracingTest method createJaxWsService.

private BookStoreService createJaxWsService(final Map<String, List<String>> headers, final Configurator configurator) throws MalformedURLException {
    JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
    factory.getOutInterceptors().add(new LoggingOutInterceptor());
    factory.getInInterceptors().add(new LoggingInInterceptor());
    factory.setServiceClass(BookStoreService.class);
    factory.setAddress("http://localhost:" + PORT + "/BookStore");
    if (configurator != null) {
        configurator.configure(factory);
    }
    final BookStoreService service = (BookStoreService) factory.create();
    final Client proxy = ClientProxy.getClient(service);
    proxy.getRequestContext().put(Message.PROTOCOL_HEADERS, headers);
    return service;
}
Also used : 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) Client(org.apache.cxf.endpoint.Client)

Aggregations

BookStoreService (org.apache.cxf.systest.jaxws.tracing.BookStoreService)19 Test (org.junit.Test)16 List (java.util.List)11 JaxWsProxyFactoryBean (org.apache.cxf.jaxws.JaxWsProxyFactoryBean)11 LoggingInInterceptor (org.apache.cxf.ext.logging.LoggingInInterceptor)5 LoggingOutInterceptor (org.apache.cxf.ext.logging.LoggingOutInterceptor)5 SOAPFaultException (javax.xml.ws.soap.SOAPFaultException)4 Tracing (brave.Tracing)3 HashMap (java.util.HashMap)3 Client (org.apache.cxf.endpoint.Client)3 TestSpanReporter (org.apache.cxf.systest.brave.TestSpanReporter)3 BraveClientFeature (org.apache.cxf.tracing.brave.BraveClientFeature)3 OpenTracingClientFeature (org.apache.cxf.tracing.opentracing.OpenTracingClientFeature)3 HTraceClientStartInterceptor (org.apache.cxf.tracing.htrace.HTraceClientStartInterceptor)2 HTraceClientStopInterceptor (org.apache.cxf.tracing.htrace.HTraceClientStopInterceptor)2 Tracer (org.apache.htrace.core.Tracer)2 Span (brave.Span)1 SpanInScope (brave.Tracer.SpanInScope)1 SpanContext (com.uber.jaeger.SpanContext)1 ActiveSpan (io.opentracing.ActiveSpan)1