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);
}
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()));
}
Aggregations