Skip to content

Commit

Permalink
Fix span management
Browse files Browse the repository at this point in the history
  • Loading branch information
pauldraper committed Feb 25, 2017
1 parent a8c505b commit 6b9beb2
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,16 @@ class ActiveTracingFilter(taggers: Traversable[SpanTagger]) extends BaseTracingF
protected[this] def tracer = GlobalTracer.get

override def apply(next: EssentialAction) = EssentialAction { request =>
val oldManagedSpan = DefaultSpanManager.getInstance.currentSpan()
val span = spanBuilder(request).start()
val managedSpan = DefaultSpanManager.getInstance.manage(span)
next(request).map { result =>
taggers.foreach(_.tag(span, request, result))
span.finish()
try {
next(request).map { result =>
taggers.foreach(_.tag(span, request, result))
span.finish()
result
}
} finally {
managedSpan.release()
DefaultSpanManager.getInstance().manage(oldManagedSpan)
result
}
}
}

0 comments on commit 6b9beb2

Please sign in to comment.