use of org.apache.cxf.tracing.htrace.jaxrs.HTraceClientProvider in project cxf by apache.
the class HTraceTracingTest method testThatNewSpansAreCreatedWhenNotProvidedUsingMultipleAsyncClients.
@Test
public void testThatNewSpansAreCreatedWhenNotProvidedUsingMultipleAsyncClients() throws Exception {
final WebClient client = createWebClient("/bookstore/books", htraceClientProvider);
// The intention is to make a calls one after another, not in parallel, to ensure the
// thread have trace contexts cleared out.
final Collection<Response> responses = IntStream.range(0, 4).mapToObj(index -> client.async().get()).map(this::get).collect(Collectors.toList());
for (final Response r : responses) {
assertEquals(Status.OK.getStatusCode(), r.getStatus());
assertTrue(r.getHeaders().containsKey(TracerHeaders.DEFAULT_HEADER_SPAN_ID));
}
assertThat(TestSpanReceiver.getAllSpans().size(), equalTo(12));
IntStream.range(0, 4).map(index -> index * 3).forEach(index -> {
assertThat(TestSpanReceiver.getAllSpans().get(index).getDescription(), equalTo("Get Books"));
assertThat(TestSpanReceiver.getAllSpans().get(index + 1).getDescription(), equalTo("GET bookstore/books"));
assertThat(TestSpanReceiver.getAllSpans().get(index + 2).getDescription(), equalTo("GET " + client.getCurrentURI()));
});
}
use of org.apache.cxf.tracing.htrace.jaxrs.HTraceClientProvider in project cxf by apache.
the class HTraceTracingCustomHeadersTest method setUp.
@Before
public void setUp() {
final Map<String, String> properties = new HashMap<>();
properties.put(Tracer.SPAN_RECEIVER_CLASSES_KEY, StandardOutSpanReceiver.class.getName());
properties.put(Tracer.SAMPLER_CLASSES_KEY, AlwaysSampler.class.getName());
tracer = new Tracer.Builder("tracer").conf(HTraceConfiguration.fromMap(properties)).build();
htraceClientProvider = new HTraceClientProvider(tracer);
}
use of org.apache.cxf.tracing.htrace.jaxrs.HTraceClientProvider in project cxf by apache.
the class HTraceTracingTest method setUp.
@Before
public void setUp() {
TestSpanReceiver.clear();
final Map<String, String> properties = new HashMap<>();
properties.put(Tracer.SPAN_RECEIVER_CLASSES_KEY, StandardOutSpanReceiver.class.getName());
properties.put(Tracer.SAMPLER_CLASSES_KEY, AlwaysSampler.class.getName());
tracer = new Tracer.Builder("tracer").conf(HTraceConfiguration.fromMap(properties)).build();
htraceClientProvider = new HTraceClientProvider(tracer);
}
use of org.apache.cxf.tracing.htrace.jaxrs.HTraceClientProvider in project cxf by apache.
the class HTraceTracingTest method testThatNewSpansAreCreatedWhenNotProvidedUsingMultipleClients.
@Test
public void testThatNewSpansAreCreatedWhenNotProvidedUsingMultipleClients() throws Exception {
final WebClient client = createWebClient("/bookstore/books", htraceClientProvider);
// The intention is to make a calls one after another, not in parallel, to ensure the
// thread have trace contexts cleared out.
final Collection<Response> responses = IntStream.range(0, 4).mapToObj(index -> client.get()).collect(Collectors.toList());
for (final Response r : responses) {
assertEquals(Status.OK.getStatusCode(), r.getStatus());
assertTrue(r.getHeaders().containsKey(TracerHeaders.DEFAULT_HEADER_SPAN_ID));
}
assertThat(TestSpanReceiver.getAllSpans().size(), equalTo(12));
IntStream.range(0, 4).map(index -> index * 3).forEach(index -> {
assertThat(TestSpanReceiver.getAllSpans().get(index).getDescription(), equalTo("Get Books"));
assertThat(TestSpanReceiver.getAllSpans().get(index + 1).getDescription(), equalTo("GET bookstore/books"));
assertThat(TestSpanReceiver.getAllSpans().get(index + 2).getDescription(), equalTo("GET " + client.getCurrentURI()));
});
}
Aggregations