use of brave.Tracing in project cxf by apache.
the class BraveTracingTest method testThatNewChildSpanIsCreatedWhenParentIsProvidedInCaseOfFault.
@Test
public void testThatNewChildSpanIsCreatedWhenParentIsProvidedInCaseOfFault() throws MalformedURLException {
final Tracing brave = Tracing.newBuilder().localServiceName("book-store").reporter(new TestSpanReporter()).build();
final BookStoreService service = createJaxWsService(new Configurator() {
@Override
public void configure(final JaxWsProxyFactoryBean factory) {
factory.getFeatures().add(new BraveClientFeature(brave));
factory.getOutInterceptors().add(new LoggingOutInterceptor());
factory.getInInterceptors().add(new LoggingInInterceptor());
}
});
try {
service.removeBooks();
fail("Expected SOAPFaultException to be raised");
} catch (final SOAPFaultException ex) {
/* expected exception */
}
assertThat(TestSpanReporter.getAllSpans().size(), equalTo(2));
assertThat(TestSpanReporter.getAllSpans().get(0).name, equalTo("post /bookstore"));
assertThat(TestSpanReporter.getAllSpans().get(1).name, equalTo("post http://localhost:" + PORT + "/bookstore"));
final Map<String, List<String>> response = getResponseHeaders(service);
assertThatTraceHeadersArePresent(response, false);
}
use of brave.Tracing in project cxf by apache.
the class BraveTracingTest method testThatNewChildSpanIsCreatedWhenParentIsProvided.
@Test
public void testThatNewChildSpanIsCreatedWhenParentIsProvided() throws MalformedURLException {
final Tracing brave = Tracing.newBuilder().localServiceName("book-store").reporter(new TestSpanReporter()).build();
final BookStoreService service = createJaxWsService(new Configurator() {
@Override
public void configure(final JaxWsProxyFactoryBean factory) {
factory.getFeatures().add(new BraveClientFeature(brave));
}
});
assertThat(service.getBooks().size(), equalTo(2));
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("post /bookstore"));
assertThat(TestSpanReporter.getAllSpans().get(2).name, equalTo("post http://localhost:" + PORT + "/bookstore"));
final Map<String, List<String>> response = getResponseHeaders(service);
assertThatTraceHeadersArePresent(response, false);
}
use of brave.Tracing in project cxf by apache.
the class BraveTracingTest method testThatNoSpansAreRecordedWhenNotSampled.
@Test
public void testThatNoSpansAreRecordedWhenNotSampled() {
final Tracing never = Tracing.newBuilder().reporter(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));
assertThatTraceHeadersArePresent(r, false);
}
use of brave.Tracing in project cxf by apache.
the class BraveTracingTest method testThatProvidedSpanIsNotClosedWhenActive.
@Test
public void testThatProvidedSpanIsNotClosedWhenActive() throws MalformedURLException {
final Tracing brave = Tracing.newBuilder().localServiceName("book-store").reporter(new TestSpanReporter()).build();
final BookStoreService service = createJaxWsService(new Configurator() {
@Override
public void configure(final JaxWsProxyFactoryBean factory) {
factory.getFeatures().add(new BraveClientFeature(brave));
}
});
final Span span = brave.tracer().nextSpan().name("test span").start();
try {
try (SpanInScope scope = brave.tracer().withSpanInScope(span)) {
assertThat(service.getBooks().size(), equalTo(2));
assertThat(brave.tracer().currentSpan(), not(nullValue()));
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("post /bookstore"));
assertThat(TestSpanReporter.getAllSpans().get(2).name, equalTo("post http://localhost:" + PORT + "/bookstore"));
final Map<String, List<String>> response = getResponseHeaders(service);
assertThatTraceHeadersArePresent(response, true);
}
} finally {
if (span != null) {
span.finish();
}
}
assertThat(TestSpanReporter.getAllSpans().size(), equalTo(4));
assertThat(TestSpanReporter.getAllSpans().get(3).name, equalTo("test span"));
}
Aggregations