aboutsummaryrefslogtreecommitdiff
path: root/src/main/scala/kamon/Kamon.scala
blob: b5998f8191e3f3c00402cb7e5e7147afe8a955e5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package kamon

import akka.actor.{Props, ActorSystem}

object Kamon {

  implicit val actorSystem = ActorSystem("kamon")

  private 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: Unit = set(newTraceContext)

  def newTraceContext(): TraceContext = TraceContext()


  val publisher = actorSystem.actorOf(Props[TransactionPublisher])

  def publish(tx: FullTransaction) = publisher ! tx

}