diff options
author | Ivan Topolnjak <ivantopo@gmail.com> | 2014-10-12 02:26:09 +0200 |
---|---|---|
committer | Ivan Topolnjak <ivantopo@gmail.com> | 2014-10-12 02:26:09 +0200 |
commit | 109ba0e17bf6d5ffbcf784e808fbb8e8f3d32a8c (patch) | |
tree | ae78312985700c2b411f027baeb073e43daece84 /kamon-core | |
parent | 30cd0ea7634615f55314c56b76fd000a52af8449 (diff) | |
download | Kamon-109ba0e17bf6d5ffbcf784e808fbb8e8f3d32a8c.tar.gz Kamon-109ba0e17bf6d5ffbcf784e808fbb8e8f3d32a8c.tar.bz2 Kamon-109ba0e17bf6d5ffbcf784e808fbb8e8f3d32a8c.zip |
= core: fix NPE when finishing segments, fixes #88
Diffstat (limited to 'kamon-core')
-rw-r--r-- | kamon-core/src/main/scala/kamon/trace/TraceContext.scala | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/kamon-core/src/main/scala/kamon/trace/TraceContext.scala b/kamon-core/src/main/scala/kamon/trace/TraceContext.scala index 6ea30511..a15a4326 100644 --- a/kamon-core/src/main/scala/kamon/trace/TraceContext.scala +++ b/kamon-core/src/main/scala/kamon/trace/TraceContext.scala @@ -26,6 +26,8 @@ import kamon.trace.TraceContextAware.DefaultTraceContextAware import kamon.trace.TraceContext.SegmentIdentity import kamon.metric.TraceMetrics.TraceMetricRecorder +import scala.annotation.tailrec + trait TraceContext { def name: String def token: String @@ -136,10 +138,12 @@ class SimpleMetricCollectionContext(traceName: String, val token: String, metada } } - private def drainFinishedSegments(metricRecorder: TraceMetricRecorder): Unit = { - while (!finishedSegments.isEmpty) { - val segmentData = finishedSegments.poll() - metricRecorder.segmentRecorder(segmentData.identity).record(segmentData.duration) + @tailrec private def drainFinishedSegments(metricRecorder: TraceMetricRecorder): Unit = { + val segment = finishedSegments.poll() + if(segment != null) { + metricRecorder.segmentRecorder(segment.identity).record(segment.duration) + println("CLOSED") + drainFinishedSegments(metricRecorder) } } |