Search in sources :

Example 61 with TraceScope

use of org.apache.htrace.core.TraceScope in project cxf by apache.

the class HTraceStopInterceptor method handleMessage.

@Override
public void handleMessage(Message message) throws Fault {
    Map<String, List<Object>> responseHeaders = CastUtils.cast((Map<?, ?>) message.get(Message.PROTOCOL_HEADERS));
    if (responseHeaders == null) {
        responseHeaders = new HashMap<>();
        message.put(Message.PROTOCOL_HEADERS, responseHeaders);
    }
    boolean isRequestor = MessageUtils.isRequestor(message);
    Message requestMessage = isRequestor ? message.getExchange().getOutMessage() : message.getExchange().getInMessage();
    Map<String, List<String>> requestHeaders = CastUtils.cast((Map<?, ?>) requestMessage.get(Message.PROTOCOL_HEADERS));
    @SuppressWarnings("unchecked") final TraceScopeHolder<TraceScope> holder = (TraceScopeHolder<TraceScope>) message.getExchange().get(TRACE_SPAN);
    super.stopTraceSpan(requestHeaders, responseHeaders, holder);
}
Also used : Message(org.apache.cxf.message.Message) TraceScope(org.apache.htrace.core.TraceScope) List(java.util.List)

Example 62 with TraceScope

use of org.apache.htrace.core.TraceScope 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

TraceScope (org.apache.htrace.core.TraceScope)62 IOException (java.io.IOException)11 InterruptedIOException (java.io.InterruptedIOException)7 MultipleIOException (org.apache.hadoop.io.MultipleIOException)6 RemoteException (org.apache.hadoop.ipc.RemoteException)5 FileNotFoundException (java.io.FileNotFoundException)4 List (java.util.List)4 SnapshotAccessControlException (org.apache.hadoop.hdfs.protocol.SnapshotAccessControlException)4 UnresolvedPathException (org.apache.hadoop.hdfs.protocol.UnresolvedPathException)4 AccessControlException (org.apache.hadoop.security.AccessControlException)4 ClosedChannelException (java.nio.channels.ClosedChannelException)3 FileAlreadyExistsException (org.apache.hadoop.fs.FileAlreadyExistsException)3 ParentNotDirectoryException (org.apache.hadoop.fs.ParentNotDirectoryException)3 DSQuotaExceededException (org.apache.hadoop.hdfs.protocol.DSQuotaExceededException)3 NSQuotaExceededException (org.apache.hadoop.hdfs.protocol.NSQuotaExceededException)3 QuotaByStorageTypeExceededException (org.apache.hadoop.hdfs.protocol.QuotaByStorageTypeExceededException)3 SpanId (org.apache.htrace.core.SpanId)3 Tracer (org.apache.htrace.core.Tracer)3 Test (org.junit.Test)3 ByteBuffer (java.nio.ByteBuffer)2