Open
Description
ClientMiddleware
could be tricky and doesn't always meet expectations.
val client: 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
.
Metadata
Assignees
Labels
No labels