You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ClientMiddleware could be tricky and doesn't always meet expectations.
valclient:Client[IO] =ClientMiddleware.default[IO].build(...)
client.run(request).use(response =>Tracer[IO].currentSpanContext.debug()) // prints None
I'm almost sure that most people would expect Tracer[IO].currentSpanContext.debug() to print an active span context there.
However, it does not work that way due to limitations: 1, 2.
What can we do?
Document why it doesn't work
Provide a workaround
A workaround could be the following:
A text map propagator (e.g. W3CContextPropagator) must be enabled to make this work
Add tracing headers to the response: resp.withHeaders(traceHeaders ++ resp.headers)
A user must explicitly join the active span via Tracer[F].joinOrRoot:
client.run(request).use { response =>Tracer[IO].joinOrRoot(response.headers)(
tracer.currentSpanContext.debug() // prints an active span context, all good
)
}
This is not the case with the ServerMiddleware because HttpRoutes isn't described as a Resource but as Kleisli.
The text was updated successfully, but these errors were encountered:
I'm not convinced this is a bug. the tracing from the middleware is around the client making the request, and using the resource of the response is not part of that
ClientMiddleware
could be tricky and doesn't always meet expectations.I'm almost sure that most people would expect
Tracer[IO].currentSpanContext.debug()
to print an active span context there.However, it does not work that way due to limitations: 1, 2.
What can we do?
A workaround could be the following:
resp.withHeaders(traceHeaders ++ resp.headers)
Tracer[F].joinOrRoot
:This is not the case with the
ServerMiddleware
becauseHttpRoutes
isn't described as aResource
but asKleisli
.The text was updated successfully, but these errors were encountered: