Hi. I think question is a bit related to arrow, bu...
# arrow
s
Hi. I think question is a bit related to arrow, but not entirely. Trying my luck anyway, since I have always gotten answers here. I have some network requests running on
IO.dispatchers().io()
and I am logging there as well, I want to tie them with MDC. Here is how I am trying, since kotlin has an mdc-slfj wrapper called
Copy code
org.jetbrains.kotlinx:kotlinx-coroutines-slf4j
that applies the matching mdc value on the new started coroutine, like this :
Copy code
MDC.put("mdc-key", "unique-mdc-value")

withContext(MDCContext()) { //withContext and MDCContext() comes from above library
    yourJobOrWhatever()
}
So I thought to apply something like this :
Copy code
IO.effect(IO.dispatchers().io()) {
    withContext(MDCContext()) {
        <http://log.info|log.info>("whatever")
    }
}
But this doesn’t work. As I have understood I need to add the new coroutine started inside
withContext
to
IO.dispatchers().io()
for it to work. But maybe I am wrong. If anyone has ideas. It will be amazing. 🙂