Make sure static mdc from withMdc set during actor startup (#29894)
* Make sure static mdc from withMdc set during actor startup #29893 * Actually assert mdc is included
This commit is contained in:
parent
df4663867d
commit
e8e62e2ca2
2 changed files with 10 additions and 4 deletions
|
|
@ -329,7 +329,7 @@ class ActorLoggingSpec extends ScalaTestWithActorTestKit("""
|
|||
"provide the MDC values in the log" in {
|
||||
val behaviors = Behaviors.withMdc[Protocol](
|
||||
Map("static" -> "1"),
|
||||
// FIXME why u no infer the type here Scala??
|
||||
// why u no infer the type here Scala??
|
||||
(message: Protocol) =>
|
||||
if (message.transactionId == 1)
|
||||
Map("txId" -> message.transactionId.toString, "first" -> "true")
|
||||
|
|
@ -348,7 +348,9 @@ class ActorLoggingSpec extends ScalaTestWithActorTestKit("""
|
|||
.info("Starting")
|
||||
// not counting for example "akkaSource", but it shouldn't have any other entries
|
||||
.withCustom(logEvent =>
|
||||
logEvent.mdc.keysIterator.forall(entry => entry.startsWith("akka") || entry == "sourceActorSystem"))
|
||||
logEvent.mdc.keysIterator.forall(entry =>
|
||||
entry.startsWith("akka") || entry == "sourceActorSystem" || entry == "static") &&
|
||||
logEvent.mdc("static") == "1")
|
||||
.expect {
|
||||
spawn(behaviors)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,8 +62,12 @@ import akka.annotation.InternalApi
|
|||
case b => b
|
||||
}
|
||||
}
|
||||
|
||||
loop(target.start(ctx))
|
||||
try {
|
||||
setMdcValues(Map.empty)
|
||||
loop(target.start(ctx))
|
||||
} finally {
|
||||
MDC.clear()
|
||||
}
|
||||
}
|
||||
|
||||
// in the normal case, a new withMDC replaces the previous one
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue