diff options
author | Diego <diegolparra@gmail.com> | 2014-11-19 22:09:41 -0300 |
---|---|---|
committer | Diego <diegolparra@gmail.com> | 2014-11-19 22:09:41 -0300 |
commit | c03a0c5dd2a490d4b4ccbde58d18ceccc1867b44 (patch) | |
tree | 4030df619b2035db49f9b10e3c8396199f154904 /kamon-core/src/test/scala/kamon/instrumentation/akka/ActorLoggingInstrumentationSpec.scala | |
parent | f6805411bbe80544d90736d560322fa6d6bd24e1 (diff) | |
download | Kamon-c03a0c5dd2a490d4b4ccbde58d18ceccc1867b44.tar.gz Kamon-c03a0c5dd2a490d4b4ccbde58d18ceccc1867b44.tar.bz2 Kamon-c03a0c5dd2a490d4b4ccbde58d18ceccc1867b44.zip |
+ core: refactor MDC facilities and closes #100
Diffstat (limited to 'kamon-core/src/test/scala/kamon/instrumentation/akka/ActorLoggingInstrumentationSpec.scala')
-rw-r--r-- | kamon-core/src/test/scala/kamon/instrumentation/akka/ActorLoggingInstrumentationSpec.scala | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/kamon-core/src/test/scala/kamon/instrumentation/akka/ActorLoggingInstrumentationSpec.scala b/kamon-core/src/test/scala/kamon/instrumentation/akka/ActorLoggingInstrumentationSpec.scala index 3dab44bc..cef335e0 100644 --- a/kamon-core/src/test/scala/kamon/instrumentation/akka/ActorLoggingInstrumentationSpec.scala +++ b/kamon-core/src/test/scala/kamon/instrumentation/akka/ActorLoggingInstrumentationSpec.scala @@ -18,11 +18,14 @@ package kamon.instrumentation.akka import akka.actor.{ Actor, ActorLogging, ActorSystem, Props } import akka.event.Logging.LogEvent import akka.testkit.TestKit -import kamon.trace.{ TraceContextAware, TraceRecorder } +import kamon.trace.TraceLocal.AvailableToMdc +import kamon.trace.logging.MdcKeysSupport +import kamon.trace.{TraceLocal, TraceContextAware, TraceRecorder} import org.scalatest.{ Inspectors, Matchers, WordSpecLike } +import org.slf4j.MDC class ActorLoggingInstrumentationSpec extends TestKit(ActorSystem("actor-logging-instrumentation-spec")) with WordSpecLike - with Matchers with Inspectors { + with Matchers with Inspectors with MdcKeysSupport { "the ActorLogging instrumentation" should { "attach the TraceContext (if available) to log events" in { @@ -42,6 +45,24 @@ class ActorLoggingInstrumentationSpec extends TestKit(ActorSystem("actor-logging case event: LogEvent ⇒ false } } + + "allow retrieve a value from the MDC when was created a key of type AvailableToMdc" in { + val testString = "Hello World" + val SampleTraceLocalKeyAvailableToMDC = AvailableToMdc("some-cool-key") + + val loggerActor = system.actorOf(Props[LoggerActor]) + system.eventStream.subscribe(testActor, classOf[LogEvent]) + + TraceRecorder.withNewTraceContext("logging-with-mdc") { + TraceLocal.store(SampleTraceLocalKeyAvailableToMDC)(testString) + + loggerActor ! "info" + + withMdc { + MDC.get("some-cool-key") should equal(testString) + } + } + } } } |