diff options
author | Ivan Topolnak <ivantopo@gmail.com> | 2013-05-16 16:37:17 -0300 |
---|---|---|
committer | Ivan Topolnak <ivantopo@gmail.com> | 2013-05-16 16:37:17 -0300 |
commit | 2845f65ba86dadea614083174e9307dc577f4583 (patch) | |
tree | 6e15b4cfb643b1e5bf6305a6e484b86c2bd20ee5 /src/main/scala/kamon/TraceContext.scala | |
parent | 52750a3eaf077fd332324fa10e2735230fd38116 (diff) | |
download | Kamon-2845f65ba86dadea614083174e9307dc577f4583.tar.gz Kamon-2845f65ba86dadea614083174e9307dc577f4583.tar.bz2 Kamon-2845f65ba86dadea614083174e9307dc577f4583.zip |
wip in aspects for actor tracing
Diffstat (limited to 'src/main/scala/kamon/TraceContext.scala')
-rw-r--r-- | src/main/scala/kamon/TraceContext.scala | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/src/main/scala/kamon/TraceContext.scala b/src/main/scala/kamon/TraceContext.scala index b137168c..1fbedf86 100644 --- a/src/main/scala/kamon/TraceContext.scala +++ b/src/main/scala/kamon/TraceContext.scala @@ -10,7 +10,21 @@ case class TraceContext(id: UUID, entries: List[TraceEntry]) { } object TraceContext { - val current = new ThreadLocal[TraceContext] + private val context = new ThreadLocal[TraceContext] + + def current = { + val ctx = context.get() + if(ctx ne null) + Some(ctx) + else + None + } + + def clear = context.remove() + + def set(ctx: TraceContext) = context.set(ctx) + + def start = set(TraceContext(UUID.randomUUID(), Nil)) } trait TraceEntry @@ -31,12 +45,12 @@ trait TraceSupport { val result = f val after = System.currentTimeMillis - swapContext(current.get().withEntry(CodeBlockExecutionTime(blockName, before, after))) + //swapContext(current.get().withEntry(CodeBlockExecutionTime(blockName, before, after))) result } def swapContext(newContext: TraceContext) { - current.set(newContext) + //current.set(newContext) } } |