Fixing some tests

This commit is contained in:
Marcin Grzejszczak
2018-01-29 10:37:49 +01:00
parent 665141d8e0
commit e85b2a78bc
4 changed files with 16 additions and 16 deletions

View File

@@ -240,7 +240,9 @@ public class TraceFilter extends GenericFilterBean {
log.debug("Will close span " + span + " since " + (shouldCloseSpan(request) ? "some component marked it for closure" : "response was unsuccessful for the root span"));
}
handler().handleSend(response, exception, span);
clearTraceAttribute(request);
if (shouldCloseSpan(request)) {
clearTraceAttribute(request);
}
} else if (span != null || requestHasAlreadyBeenHandled(request)) {
if (log.isDebugEnabled()) {
log.debug("Detaching the span " + span + " since the response was unsuccessful");

View File

@@ -151,16 +151,6 @@ public class BraveTracerTest {
.sampled(true).build());
}
@Test public void extractTraceContextReturnsNull() throws Exception {
Map<String, String> map = new LinkedHashMap<>();
map.put("other", "1");
BraveSpanContext openTracingContext = opentracing.extract(Format.Builtin.HTTP_HEADERS,
new TextMapExtractAdapter(map));
assertThat(openTracingContext).isNull();
}
@Test public void injectTraceContext_baggage() throws Exception {
BraveSpan span = opentracing.buildSpan("foo").start();
span.setBaggageItem("country-code", "FO");

View File

@@ -6,6 +6,7 @@ import brave.Span;
import brave.Tracer;
import brave.Tracing;
import brave.sampler.Sampler;
import org.junit.BeforeClass;
import reactor.core.publisher.BaseSubscriber;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Hooks;

View File

@@ -80,13 +80,20 @@ public class TraceFilterWebIntegrationTests {
}
then(Tracing.current().tracer().currentSpan()).isNull();
then(this.accumulator.getSpans()).hasSize(1);
Span reportedSpan = this.accumulator.getSpans().get(0);
then(reportedSpan.tags())
then(this.accumulator.getSpans()).hasSize(2);
Span fromFirstTraceFilterFlow = this.accumulator.getSpans().get(0);
then(fromFirstTraceFilterFlow.tags())
.containsEntry("http.status_code", "500")
.containsEntry("error", "Request processing failed; nested exception is java.lang.RuntimeException: Throwing exception");
.containsEntry("http.method", "GET")
.containsEntry("error", "Request processing failed; nested exception is java.lang.RuntimeException: Throwing exception")
.containsEntry("mvc.controller.class", "ExceptionThrowingController");
Span fromErrorController = this.accumulator.getSpans().get(1);
then(fromErrorController.tags())
.containsEntry("http.status_code", "500")
.containsEntry("error", "Request processing failed; nested exception is java.lang.RuntimeException: Throwing exception")
.containsEntry("mvc.controller.class", "BasicErrorController");
// issue#714
String hex = reportedSpan.traceId();
String hex = fromErrorController.traceId();
String[] split = capture.toString().split("\n");
List<String> list = Arrays.stream(split).filter(s -> s.contains(
"Uncaught exception thrown"))