Satyam Agarwal
02/04/2020, 8:41 AMIO.effect(IO.dispatchers().io() + MDCContext())
doesn’t work, but IO.effect(MDCContext())
works.
I am trying to put MDC correlation id on all the logs that gets produced on IO.dispatchers().io()
simon.vergauwen
02/04/2020, 9:15 AMSatyam Agarwal
02/04/2020, 12:51 PMid
s are not getting added with IO.dispatchers().io() + MDCContext()
Logs do get printed on right pool. for example, whatever
log message from example above gets printed on io-arrow-kt-worker-0
Satyam Agarwal
02/04/2020, 12:52 PMIO.effect(MDCContext())
id
s get attach toosimon.vergauwen
02/04/2020, 12:56 PM+
you should be able to debug how the get added to each-other.
It sounds like something is going wrong their and IO.dispatchers().io() + MDCContext()
is resulting in the wrong combination of CorotuineContext
simon.vergauwen
02/04/2020, 12:56 PMIO.dispatchers().io()
just uses the default impl from the stdSatyam Agarwal
02/04/2020, 12:58 PMSatyam Agarwal
02/04/2020, 1:11 PMsimon.vergauwen
02/04/2020, 1:12 PMsimon.vergauwen
02/04/2020, 1:17 PMIO
? I think it’s related to the KotlinX machinery, and that ThreadContextElement
is not working correctly outside of KotlinX since it’s a libray.simon.vergauwen
02/04/2020, 1:19 PMimplementation "io.arrow-kt:arrow-fx-kotlinx-coroutines:0.10.5-SNAPSHOT"
simon.vergauwen
02/04/2020, 1:20 PMsuspendCancelable
which uses the Continuation
used by KotlinX under the hood instead of the Continuation
from Kotlin’s standard library.simon.vergauwen
02/04/2020, 1:20 PMunsafeRunScoped
to run `IO`’s within structured concurrency with CoroutineScope
simon.vergauwen
02/04/2020, 1:21 PMSatyam Agarwal
02/04/2020, 1:24 PMSatyam Agarwal
02/04/2020, 1:24 PMfun Route.sendOk() {
get("/status") {
IO
.invoke(IO.dispatchers().io()) {
<http://log.info|log.info>("whatever")
}
.flatMap { IO.effect(IO.dispatchers().io()) { this.call.respond("ok") } }
.suspended()
}
}
Satyam Agarwal
02/04/2020, 1:25 PMsimon.vergauwen
02/04/2020, 1:26 PMsimon.vergauwen
02/04/2020, 1:26 PMsuspendCancelable
instead?simon.vergauwen
02/04/2020, 1:27 PMContinuation
interface instead of the one from the standard library.simon.vergauwen
02/04/2020, 1:27 PMThreadContextElement<MDCContextMap>
does, since ThreadContextElement
is not in the standard library put specific to Kotlinx sadly.Satyam Agarwal
02/04/2020, 1:29 PMsuspended()
?
Yes I can give it a try. I will post in some time how it went. And thank you again @simon.vergauwen ❤️simon.vergauwen
02/04/2020, 1:29 PMSatyam Agarwal
02/04/2020, 2:54 PMSatyam Agarwal
02/04/2020, 2:56 PMsimon.vergauwen
02/04/2020, 6:22 PM