use of org.apache.cxf.tracing.brave.jaxrs.BraveClientProvider in project cxf by apache.
the class BraveTracingTest method setUp.
@Before
public void setUp() {
TestSpanReporter.clear();
brave = Tracing.newBuilder().reporter(new TestSpanReporter()).sampler(Sampler.ALWAYS_SAMPLE).build();
braveClientProvider = new BraveClientProvider(brave);
random = new Random();
}
use of org.apache.cxf.tracing.brave.jaxrs.BraveClientProvider in project cxf by apache.
the class BraveTracingTest method testThatProvidedSpanIsNotDetachedWhenActiveUsingAsyncClient.
@Test
public void testThatProvidedSpanIsNotDetachedWhenActiveUsingAsyncClient() throws Exception {
final WebClient client = createWebClient("/bookstore/books", new BraveClientProvider(brave));
final Span span = brave.tracer().nextSpan().name("test span").start();
try (SpanInScope scope = brave.tracer().withSpanInScope(span)) {
final Future<Response> f = client.async().get();
final Response r = f.get(1, TimeUnit.SECONDS);
assertEquals(Status.OK.getStatusCode(), r.getStatus());
assertThat(brave.tracer().currentSpan().context().spanId(), equalTo(span.context().spanId()));
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()));
} finally {
span.finish();
}
// Await till flush happens, usually a second is enough
await().atMost(Duration.ofSeconds(1L)).until(() -> TestSpanReporter.getAllSpans().size() == 4);
assertThat(TestSpanReporter.getAllSpans().size(), equalTo(4));
assertThat(TestSpanReporter.getAllSpans().get(3).name(), equalTo("test span"));
}
use of org.apache.cxf.tracing.brave.jaxrs.BraveClientProvider in project cxf by apache.
the class BraveTracingTest method testThatProvidedSpanIsNotClosedWhenActive.
@Test
public void testThatProvidedSpanIsNotClosedWhenActive() throws MalformedURLException {
final WebClient client = createWebClient("/bookstore/books", new BraveClientProvider(brave));
final Span span = brave.tracer().nextSpan().name("test span").start();
try (SpanInScope scope = brave.tracer().withSpanInScope(span)) {
final Response r = client.get();
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(0).parentId(), not(nullValue()));
assertThat(TestSpanReporter.getAllSpans().get(1).name(), equalTo("get /bookstore/books"));
assertThat(TestSpanReporter.getAllSpans().get(2).name(), equalTo("get " + client.getCurrentURI()));
} finally {
span.finish();
}
// Await till flush happens, usually a second is enough
await().atMost(Duration.ofSeconds(1L)).until(() -> TestSpanReporter.getAllSpans().size() == 4);
assertThat(TestSpanReporter.getAllSpans().size(), equalTo(4));
assertThat(TestSpanReporter.getAllSpans().get(3).name(), equalTo("test span"));
}
use of org.apache.cxf.tracing.brave.jaxrs.BraveClientProvider in project cxf by apache.
the class BraveTracingTest method setUp.
@Before
public void setUp() {
TestSpanHandler.clear();
brave = Tracing.newBuilder().addSpanHandler(new TestSpanHandler()).sampler(Sampler.ALWAYS_SAMPLE).build();
braveClientProvider = new BraveClientProvider(brave);
}
use of org.apache.cxf.tracing.brave.jaxrs.BraveClientProvider in project cxf by apache.
the class BraveTracingTest method testThatNewChildSpanIsCreatedWhenParentIsProvided.
@Test
public void testThatNewChildSpanIsCreatedWhenParentIsProvided() {
final Response r = createWebClient("/bookstore/books", new BraveClientProvider(brave)).get();
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(0).parentId(), not(nullValue()));
}
Aggregations