Change scope handling

This commit is contained in:
Gary Huang 2018-12-07 12:40:18 -05:00
parent 26c354dad2
commit a04b30107f
No known key found for this signature in database
GPG Key ID: 0CB168EE6C6844B7
1 changed files with 7 additions and 6 deletions

View File

@ -4,6 +4,7 @@ import datadog.trace.api.DDSpanTypes
import datadog.trace.api.DDTags
import datadog.trace.context.TraceScope
import io.opentracing.Scope
import io.opentracing.Span
import io.opentracing.tag.Tags
import io.opentracing.util.GlobalTracer
import okhttp3.HttpUrl
@ -314,18 +315,18 @@ class RatpackTest extends AgentTestRunner {
GlobalTracer.get()
.buildSpan("ratpack.exec-test")
.withTag(DDTags.RESOURCE_NAME, "INSIDE-TEST")
.startActive(true)
.startActive(false)
if (startSpanInHandler) {
((TraceScope) scope).setAsyncPropagation(true)
}
scope.span().setBaggageItem("test-baggage", "foo")
context.onClose {
final Span startedSpan = startSpanInHandler ? scope.span() : null
if (startSpanInHandler) {
final Scope activeScope = GlobalTracer.get().scopeManager().active()
((TraceScope) activeScope).setAsyncPropagation(false)
activeScope.close()
scope.close()
context.onClose {
startedSpan.finish()
}
}