Open scprek opened 1 year ago
Was this ever resolved?
I don’t think so, I ended up just writing extensions like this in a shared library for teams to use.
import io.opentelemetry.context.Context
import io.opentelemetry.extension.kotlin.asContextElement
import kotlin.coroutines.CoroutineContext
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.slf4j.MDCContext
/**
* Modifies the defaults of [runBlocking] by automatically including the [MDCContext] and [asContextElement] of OTEL
* and using the Blocking Thread
*/
fun <T> runBlockingWithContext(context: CoroutineContext = Dispatchers.IO + MDCContext() + Context.current().asContextElement(), block: suspend CoroutineScope.() -> T): T {
return runBlocking(context, block)
}
Thanks for sharing this! I'm still trying to hack it into working, I'll report if I make a breakthrough ...
@dstepanov can you document this and fix the docs?
Issue description
I expect there to be information about how Tracing context is passed to coroutines and in the micronaut core docs there is a section https://docs.micronaut.io/latest/guide/index.html#coroutineTracingContextPropagation which references the class
CoroutineTracingDispatcher
that no longer exists. I assume this was due to the launch of https://micronaut-projects.github.io/micronaut-tracing/latest/guide/ and it's unclear to me if a context still needs to be added or not.