-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Blaze client loses context in callback #32
Comments
I'll prepare a repro... Also, this is when I'm not using kamon-scala-future / kamon-cats-io (the only modules of kamon I have are zipkin, logback and http4s). I had this wrapping every ExecutionContext in the world: final class KamonExecutionContext(underlying: ExecutionContext) extends ExecutionContext {
def execute(runnable: Runnable): Unit = {
val ctx = Kamon.currentContext()
underlying.execute(() => Kamon.runWithContext(ctx)(runnable.run()))
}
def reportFailure(cause: Throwable): Unit = underlying.reportFailure(cause)
} Including the EC passed to BlazeClientBuilder, the one in IO.contextShift and IO.timer. I also tried removing that and using kamon-scala-future + kamon-cats-io, but that didn't help (same result). |
I also prepared one in which kamon-cats-io and kamon-scala-future are used instead of custom instrumentation. Same rules to run :) |
Hey! From glancing over it, it seems that context gets lost after I would try it with |
Isn't that included in the futures module? |
Hey guys!, my output is:
I found this mesage:
and for that reason I ran the example with:
|
@dpsoft I'm attaching Kanela manually in bloop, but it's fine to add forking if you're running through sbt :) The output is consistent with mine - I can't see the trace/span IDs in the "Executed request" messages. |
@kubukoz this is my output:
using the
|
:/ |
Is there an easy way to instrument |
I tried by reenabling instrumentation on |
@mladens you are reenabling the instrumentation on |
@kubukoz @mladens In order to instrument package kamon.instrumentation.handler
import kamon.instrumentation.context.{CaptureCurrentContextOnExit, HasContext, InvokeWithCapturedContext}
import kanela.agent.api.instrumentation.InstrumentationBuilder
class CompletionHandlerInstrumentation extends InstrumentationBuilder {
onSubTypesOf("java.nio.channels.CompletionHandler")
.mixin(classOf[HasContext.Mixin])
.advise(isConstructor, CaptureCurrentContextOnExit)
.advise(method("completed"), InvokeWithCapturedContext)
} in
and the output with this instrumentation is:
|
Hello! I just encountered this issue myself. |
Hi!
I'm playing with kamon-http4s again and I'm trying to wrap the blaze client with the middleware. Unfortunately, my context gets lost at the point Blaze creates a connection. I tracked it down to here:
As far as I understand, the context should somehow be passed to the completion handler at instantiation time and restored in
def completed
, before completing the promise (then the further transformations on the future would also have the context, which they don't - so even though all the tracing information is in the request thanks to the middleware, the Kamon context has no span after any client call).Can this be done somehow through the configuration of the agent, or would it require special treatment in blaze (e.g. being able to inject a method that creates the completion handler)?
The text was updated successfully, but these errors were encountered: