heyhey, I am trying to create a Ktor server plugin where I want to set a custom coroutine context (
withContext
), that should be used when handling requests. (I want to create an active span with opentelemetry-extension-kotlin that is tied to the coroutine context). Looking through the examples I can only see before and after hooks, but nothing like an around interceptor. Any ideas?
a
Aleksei Tirman [JB]
06/02/2022, 8:04 AM
You can still use interceptors if you need.
m
martinm
06/02/2022, 8:45 AM
Is there an existing plugin that does something similar? I am struggling to see how this can be done.
Copy code
pipeline.intercept(ApplicationCallPipeline.Call) {
withContext(myContext){
// how to proceed here?
}
}