Fix Flaky Ratpack Fork Test

Ratpack tests occasionally fail with the handler span and manually started span out of order. This will ensure that if a span is manually started inside of the handler then it will be finished after the handler span is finished, which is when the request has been responded to.
This commit is contained in:
Gary Huang 2018-12-07 00:44:27 -05:00
parent 44aadf36ce
commit 26c354dad2
No known key found for this signature in database
GPG Key ID: 0CB168EE6C6844B7
1 changed files with 8 additions and 4 deletions

View File

@ -320,12 +320,16 @@ class RatpackTest extends AgentTestRunner {
((TraceScope) scope).setAsyncPropagation(true) ((TraceScope) scope).setAsyncPropagation(true)
} }
scope.span().setBaggageItem("test-baggage", "foo") scope.span().setBaggageItem("test-baggage", "foo")
context.render(testPromise().fork())
if (startSpanInHandler) { context.onClose {
((TraceScope) scope).setAsyncPropagation(false) if (startSpanInHandler) {
final Scope activeScope = GlobalTracer.get().scopeManager().active()
((TraceScope) activeScope).setAsyncPropagation(false)
activeScope.close()
}
} }
scope.close()
context.render(testPromise().fork())
} }
} }
} }