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 | 827644d92a216172cd587f253c1fc1a0bbdb5eaf (patch) | |
tree | 52883845f601cca03f5e299be536b4d9b013b48a /kamon-core/src/test/scala/kamon/instrumentation/akka/ActorLoggingInstrumentationSpec.scala | |
parent | d990039c7e0a3b6a909f93dc477fc7aaf4907e42 (diff) | |
download | Kamon-827644d92a216172cd587f253c1fc1a0bbdb5eaf.tar.gz Kamon-827644d92a216172cd587f253c1fc1a0bbdb5eaf.tar.bz2 Kamon-827644d92a216172cd587f253c1fc1a0bbdb5eaf.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) + } + } + } } } |