Search in sources :

Example 1 with BookStoreService

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

the class HTraceTracingTest method testThatNewInnerSpanIsCreated.

@Test
public void testThatNewInnerSpanIsCreated() throws MalformedURLException {
    final SpanId spanId = SpanId.fromRandom();
    final Map<String, List<String>> headers = new HashMap<>();
    headers.put(TracerHeaders.DEFAULT_HEADER_SPAN_ID, Arrays.asList(spanId.toString()));
    final BookStoreService service = createJaxWsService(headers);
    assertThat(service.getBooks().size(), equalTo(2));
    assertThat(TestSpanReceiver.getAllSpans().size(), equalTo(2));
    assertThat(TestSpanReceiver.getAllSpans().get(0).getDescription(), equalTo("Get Books"));
    assertThat(TestSpanReceiver.getAllSpans().get(1).getDescription(), equalTo("POST /BookStore"));
    final Map<String, List<String>> response = getResponseHeaders(service);
    assertThat(response.get(TracerHeaders.DEFAULT_HEADER_SPAN_ID), hasItems(spanId.toString()));
}
Also used : HashMap(java.util.HashMap) BookStoreService(org.apache.cxf.systest.jaxws.tracing.BookStoreService) List(java.util.List) SpanId(org.apache.htrace.core.SpanId) Test(org.junit.Test)

Example 2 with BookStoreService

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

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

the class HTraceTracingTest 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)

Example 4 with BookStoreService

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

the class BraveTracingTest method createJaxWsService.

private BookStoreService createJaxWsService(final Map<String, List<String>> headers, final Feature feature) {
    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 (feature != null) {
        factory.getFeatures().add(feature);
    }
    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)

Example 5 with BookStoreService

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

the class BraveTracingTest method testThatNewInnerSpanIsCreated.

@Test
public void testThatNewInnerSpanIsCreated() throws Exception {
    final Random random = new Random();
    final SpanId spanId = new SpanId().traceId(random.nextLong()).parentId(random.nextLong()).spanId(random.nextLong()).sampled(true);
    final Map<String, List<String>> headers = new HashMap<>();
    headers.put(SPAN_ID_NAME, Arrays.asList(Long.toString(spanId.spanId())));
    headers.put(TRACE_ID_NAME, Arrays.asList(Long.toString(spanId.traceId())));
    headers.put(SAMPLED_NAME, Arrays.asList(Boolean.toString(spanId.sampled())));
    headers.put(PARENT_SPAN_ID_NAME, Arrays.asList(Long.toString(spanId.parentId())));
    final BookStoreService service = createJaxWsService(headers);
    assertThat(service.getBooks().size(), equalTo(2));
    assertThat(TestSpanReporter.getAllSpans().size(), equalTo(2));
    assertThat(TestSpanReporter.getAllSpans().get(0).name(), equalTo("get books"));
    assertThat(TestSpanReporter.getAllSpans().get(1).name(), equalTo("post /bookstore"));
}
Also used : Random(java.util.Random) HashMap(java.util.HashMap) BookStoreService(org.apache.cxf.systest.jaxws.tracing.BookStoreService) List(java.util.List) SpanId(org.apache.cxf.systest.brave.BraveTestSupport.SpanId) Test(org.junit.Test)

Aggregations

BookStoreService (org.apache.cxf.systest.jaxws.tracing.BookStoreService)23 Test (org.junit.Test)18 List (java.util.List)8 JaxWsProxyFactoryBean (org.apache.cxf.jaxws.JaxWsProxyFactoryBean)7 Client (org.apache.cxf.endpoint.Client)5 LoggingInInterceptor (org.apache.cxf.ext.logging.LoggingInInterceptor)5 LoggingOutInterceptor (org.apache.cxf.ext.logging.LoggingOutInterceptor)5 Tracing (brave.Tracing)4 SOAPFaultException (javax.xml.ws.soap.SOAPFaultException)4 BraveClientFeature (org.apache.cxf.tracing.brave.BraveClientFeature)4 OpenTracingClientFeature (org.apache.cxf.tracing.opentracing.OpenTracingClientFeature)4 HashMap (java.util.HashMap)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 JaegerSpanContext (io.jaegertracing.internal.JaegerSpanContext)1 Scope (io.opentracing.Scope)1 Span (io.opentracing.Span)1