diff options
author | Ivan Topolnak <ivantopo@gmail.com> | 2013-05-24 15:28:30 -0300 |
---|---|---|
committer | Ivan Topolnak <ivantopo@gmail.com> | 2013-05-24 15:28:30 -0300 |
commit | 1b2bc32d62e5955fae291ed7daaa57b48c0de48e (patch) | |
tree | 777530574d60e2ba3f5381cb808efe1b84c74c66 /src/main/scala/kamon | |
parent | 4dab50d280053b410dbb421c7f8a0182c8b27b78 (diff) | |
download | Kamon-1b2bc32d62e5955fae291ed7daaa57b48c0de48e.tar.gz Kamon-1b2bc32d62e5955fae291ed7daaa57b48c0de48e.tar.bz2 Kamon-1b2bc32d62e5955fae291ed7daaa57b48c0de48e.zip |
Added a simple test of futures instrumentation
Diffstat (limited to 'src/main/scala/kamon')
-rw-r--r-- | src/main/scala/kamon/TraceContext.scala | 16 | ||||
-rw-r--r-- | src/main/scala/kamon/instrumentation/PromiseCompletingRunnableInstrumentation.scala | 2 |
2 files changed, 7 insertions, 11 deletions
diff --git a/src/main/scala/kamon/TraceContext.scala b/src/main/scala/kamon/TraceContext.scala index 18a91145..5787167b 100644 --- a/src/main/scala/kamon/TraceContext.scala +++ b/src/main/scala/kamon/TraceContext.scala @@ -10,19 +10,15 @@ case class TraceContext(id: UUID, entries: List[TraceEntry]) { } object TraceContext { - private val context = new ThreadLocal[TraceContext] - - def current = { - val ctx = context.get() - if(ctx ne null) - Some(ctx) - else - None + private val context = new ThreadLocal[Option[TraceContext]] { + override def initialValue(): Option[TraceContext] = None } - def clear = context.remove() + def current = context.get - def set(ctx: TraceContext) = context.set(ctx) + def clear = context.remove + + def set(ctx: TraceContext) = context.set(Some(ctx)) def start = set(TraceContext(UUID.randomUUID(), Nil)) } diff --git a/src/main/scala/kamon/instrumentation/PromiseCompletingRunnableInstrumentation.scala b/src/main/scala/kamon/instrumentation/PromiseCompletingRunnableInstrumentation.scala index dde0d857..323951f9 100644 --- a/src/main/scala/kamon/instrumentation/PromiseCompletingRunnableInstrumentation.scala +++ b/src/main/scala/kamon/instrumentation/PromiseCompletingRunnableInstrumentation.scala @@ -7,7 +7,7 @@ import org.aspectj.lang.ProceedingJoinPoint @Aspect("perthis(promiseCompletingRunnableCreation())") class PromiseCompletingRunnableInstrumentation { - private var traceContext: Option[TraceContext] = None + @volatile private var traceContext: Option[TraceContext] = None @Pointcut("execution(scala.concurrent.impl.Future.PromiseCompletingRunnable.new(..))") def promiseCompletingRunnableCreation(): Unit = {} |