use of org.apache.cxf.tracing.brave.jaxrs.BraveClientProvider in project cxf by apache.
the class BraveTracingTest method testThatNewSpansAreCreatedWhenNotProvidedUsingMultipleClients.
@Test
public void testThatNewSpansAreCreatedWhenNotProvidedUsingMultipleClients() throws Exception {
final WebClient client = createWebClient("/bookstore/books", new BraveClientProvider(brave));
// The intention is to make a calls one after another, not in parallel, to ensure the
// thread have trace contexts cleared out.
IntStream.range(0, 4).mapToObj(index -> client.get()).forEach(r -> assertEquals(Status.OK.getStatusCode(), r.getStatus()));
assertThat(TestSpanReporter.getAllSpans().size(), equalTo(12));
IntStream.range(0, 4).map(index -> index * 3).forEach(index -> {
assertThat(TestSpanReporter.getAllSpans().get(index).name(), equalTo("get books"));
assertThat(TestSpanReporter.getAllSpans().get(index + 1).name(), equalTo("get /bookstore/books"));
assertThat(TestSpanReporter.getAllSpans().get(index + 2).name(), equalTo("get " + client.getCurrentURI()));
});
}
use of org.apache.cxf.tracing.brave.jaxrs.BraveClientProvider in project cxf by apache.
the class BraveTracingTest method testThatNoSpansAreRecordedWhenNotSampled.
@Test
public void testThatNoSpansAreRecordedWhenNotSampled() {
final Tracing never = Tracing.newBuilder().spanReporter(new TestSpanReporter()).sampler(Sampler.NEVER_SAMPLE).build();
final Response r = createWebClient("/bookstore/books", new BraveClientProvider(never)).get();
assertEquals(Status.OK.getStatusCode(), r.getStatus());
assertThat(TestSpanReporter.getAllSpans().size(), equalTo(0));
}
use of org.apache.cxf.tracing.brave.jaxrs.BraveClientProvider in project cxf by apache.
the class BraveTracingTest method testThatNewSpansAreCreatedWhenNotProvidedUsingMultipleAsyncClients.
@Test
public void testThatNewSpansAreCreatedWhenNotProvidedUsingMultipleAsyncClients() throws Exception {
final WebClient client = createWebClient("/bookstore/books", new BraveClientProvider(brave));
// The intention is to make a calls one after another, not in parallel, to ensure the
// thread have trace contexts cleared out.
IntStream.range(0, 4).mapToObj(index -> client.async().get()).map(this::get).forEach(r -> assertEquals(Status.OK.getStatusCode(), r.getStatus()));
assertThat(TestSpanReporter.getAllSpans().toString(), TestSpanReporter.getAllSpans().size(), equalTo(12));
IntStream.range(0, 4).map(index -> index * 3).forEach(index -> {
assertThat(TestSpanReporter.getAllSpans().get(index).name(), equalTo("get books"));
assertThat(TestSpanReporter.getAllSpans().get(index + 1).name(), equalTo("get /bookstore/books"));
assertThat(TestSpanReporter.getAllSpans().get(index + 2).name(), equalTo("get " + client.getCurrentURI()));
});
}
use of org.apache.cxf.tracing.brave.jaxrs.BraveClientProvider in project cxf by apache.
the class BraveTracingTest method testThatNewSpanIsCreatedWhenNotProvidedUsingAsyncClient.
@Test
public void testThatNewSpanIsCreatedWhenNotProvidedUsingAsyncClient() throws Exception {
final WebClient client = createWebClient("/bookstore/books", new BraveClientProvider(brave));
final Future<Response> f = client.async().get();
final Response r = f.get(1, TimeUnit.SECONDS);
assertEquals(Status.OK.getStatusCode(), r.getStatus());
assertThat(TestSpanReporter.getAllSpans().size(), equalTo(3));
assertThat(TestSpanReporter.getAllSpans().get(0).name(), equalTo("get books"));
assertThat(TestSpanReporter.getAllSpans().get(1).name(), equalTo("get /bookstore/books"));
assertThat(TestSpanReporter.getAllSpans().get(2).name(), equalTo("get " + client.getCurrentURI()));
}
Aggregations