Hi guys, I have some code that relies on MDC to lo...
# ktor
l
Hi guys, I have some code that relies on MDC to log some context data (SessionID for example). I use Ktor Http Client to call some REST services, with OkHttp. I understand that the OkHttp calls are made using coroutines and I don't have access to MDC data that is based on
ThreadLocal
. I saw that
kotlinx.coroutines.slf4j
introduces
MDCContext()
and that, this way, you can launch some coroutines passing them MDC data. But is there a way I can use it to propagate my MDC data to the underlying OkHttp calls ?
m
Perhaps the approach I use in https://bitbucket.org/marshallpierce/gcp-logging-enhancers/src/master/ might work for you. See the ktor submodule.
Thi is one of the things I love about KTOR, it was so painful to do in ReactiveX+OKHTTP
l
Thanks guys