diff options
author | Ivan Topolnak <ivantopo@gmail.com> | 2013-06-06 18:03:20 -0300 |
---|---|---|
committer | Ivan Topolnak <ivantopo@gmail.com> | 2013-06-06 18:03:20 -0300 |
commit | 197746563e47783ed4b5f43e94c9aa63734081f6 (patch) | |
tree | c233afe3560a1f3cdaf33f6edcbd23b3a196b5f1 /src | |
parent | 695b9b6d2bdf55afd7fe420d9a6fc36d3d45ed31 (diff) | |
download | Kamon-197746563e47783ed4b5f43e94c9aa63734081f6.tar.gz Kamon-197746563e47783ed4b5f43e94c9aa63734081f6.tar.bz2 Kamon-197746563e47783ed4b5f43e94c9aa63734081f6.zip |
wip
Diffstat (limited to 'src')
-rw-r--r-- | src/main/scala/kamon/Kamon.scala | 21 | ||||
-rw-r--r-- | src/main/scala/kamon/TraceContext.scala | 34 |
2 files changed, 55 insertions, 0 deletions
diff --git a/src/main/scala/kamon/Kamon.scala b/src/main/scala/kamon/Kamon.scala index ef5f8044..c1b97722 100644 --- a/src/main/scala/kamon/Kamon.scala +++ b/src/main/scala/kamon/Kamon.scala @@ -29,3 +29,24 @@ object Kamon { def publish(tx: FullTransaction) = publisher ! tx } + + + +object Tracer { + val ctx = new ThreadLocal[Option[TraceContext]] { + override def initialValue() = None + } + + def context() = ctx.get() + def clear = ctx.remove() + def set(traceContext: TraceContext) = ctx.set(Some(traceContext)) + + def start = ??? //set(newTraceContext) + def stop = ctx.get match { + case Some(context) => context.close + case None => + } + + //def newTraceContext(): TraceContext = TraceContext() + +} diff --git a/src/main/scala/kamon/TraceContext.scala b/src/main/scala/kamon/TraceContext.scala index 19ebc578..351446f3 100644 --- a/src/main/scala/kamon/TraceContext.scala +++ b/src/main/scala/kamon/TraceContext.scala @@ -28,3 +28,37 @@ object TraceContext { trait TraceEntry case class CodeBlockExecutionTime(name: String, begin: Long, end: Long) extends TraceEntry + + + +case class TransactionTrace(id: UUID, start: Long, end: Long, entries: Seq[TraceEntry]) + + + + + +object Collector { + +} + +trait TraceEntryStorage { + def store(entry: TraceEntry): Boolean +} + +class TransactionContext(val id: UUID, private val storage: TraceEntryStorage) { + def store(entry: TraceEntry) = storage.store(entry) +} + +object ThreadLocalTraceEntryStorage extends TraceEntryStorage { + + private val storage = new ThreadLocal[List[TraceEntry]] { + override def initialValue(): List[TraceEntry] = Nil + def update(f: List[TraceEntry] => List[TraceEntry]) = set(f(get())) + } + + def store(entry: TraceEntry): Boolean = { + storage.update(entry :: _) + true + } +} + |