aboutsummaryrefslogtreecommitdiff
path: root/src/main/scala/kamon/Kamon.scala
diff options
context:
space:
mode:
authorIvan Topolnak <ivantopo@gmail.com>2013-06-03 12:46:56 -0300
committerIvan Topolnak <ivantopo@gmail.com>2013-06-03 12:46:56 -0300
commit695b9b6d2bdf55afd7fe420d9a6fc36d3d45ed31 (patch)
treeaff9e74f6b5838f186ba8ef9e6053d9ad4c84ea2 /src/main/scala/kamon/Kamon.scala
parentcad83e95166d91225e126aa6a0fab493b3baca59 (diff)
parentda47788738055e4fef1485f2721c6ee040c16fd8 (diff)
downloadKamon-695b9b6d2bdf55afd7fe420d9a6fc36d3d45ed31.tar.gz
Kamon-695b9b6d2bdf55afd7fe420d9a6fc36d3d45ed31.tar.bz2
Kamon-695b9b6d2bdf55afd7fe420d9a6fc36d3d45ed31.zip
Merged the aspects-refactor changes
Diffstat (limited to 'src/main/scala/kamon/Kamon.scala')
-rw-r--r--src/main/scala/kamon/Kamon.scala31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/main/scala/kamon/Kamon.scala b/src/main/scala/kamon/Kamon.scala
new file mode 100644
index 00000000..ef5f8044
--- /dev/null
+++ b/src/main/scala/kamon/Kamon.scala
@@ -0,0 +1,31 @@
+package kamon
+
+import akka.actor.{Props, ActorSystem}
+
+object Kamon {
+
+ val ctx = new ThreadLocal[Option[TraceContext]] {
+ override def initialValue() = None
+ }
+
+ implicit lazy val actorSystem = ActorSystem("kamon")
+
+
+ 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()
+
+
+ val publisher = actorSystem.actorOf(Props[TransactionPublisher])
+
+ def publish(tx: FullTransaction) = publisher ! tx
+
+}