Add flow-id to MDC

This commit is contained in:
Andras Slemmer 2018-04-25 10:36:50 +01:00
parent f1da044c86
commit 29dbe6ab53

View File

@ -28,6 +28,7 @@ import net.corda.nodeapi.internal.persistence.contextTransaction
import net.corda.nodeapi.internal.persistence.contextTransactionOrNull
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import org.slf4j.MDC
import java.util.concurrent.TimeUnit
import kotlin.reflect.KProperty1
@ -164,11 +165,16 @@ class FlowStateMachineImpl<R>(override val id: StateMachineRunId,
}
}
fun setLoggingContext() {
context.pushToLoggingContext()
MDC.put("flow-id", id.uuid.toString())
}
@Suspendable
override fun run() {
logic.stateMachine = this
context.pushToLoggingContext()
setLoggingContext()
initialiseFlow()
@ -321,6 +327,7 @@ class FlowStateMachineImpl<R>(override val id: StateMachineRunId,
require(continuation == FlowContinuation.ProcessEvents)
Fiber.unparkDeserialized(this, scheduler)
}
setLoggingContext()
return uncheckedCast(processEventsUntilFlowIsResumed(
isDbTransactionOpenOnEntry = false,
isDbTransactionOpenOnExit = true