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
My project with fiber extensively uses the context provided by fiber at c.Context() - not c.UserContext(). That is, middlewares operate on c.Context() (I believe also most official/contrib ones do), and then handlers deal with transport stuff and ultimately call "business logic" code, passing c.Context(). The docs are not clear about the distinction.
The opentel middleware uses c.UserContext(), and nicely starts a span when handling a request, but that span is not set on c.Context(). I suspect this simply is because there is a method c.SetUserContext() but no c.SetContext(). The opentel package itself does not expose the context key in any way and so it is impossible to copy the value from one to the other. The opentel package follow the conical (to my knowledge) way of creating a new ctx var á la ctx, err = SetThing(ctx), which is inherently incompatible with fiber's c.Context().
In other words, it is not possible to use trace.Tracer.Start with fiber's c.Context(), only c.UserContext().
What can I do in this scenario?
The text was updated successfully, but these errors were encountered:
Question Description
My project with fiber extensively uses the context provided by fiber at
c.Context()
- notc.UserContext()
. That is, middlewares operate onc.Context()
(I believe also most official/contrib ones do), and then handlers deal with transport stuff and ultimately call "business logic" code, passingc.Context()
. The docs are not clear about the distinction.The opentel middleware uses
c.UserContext()
, and nicely starts a span when handling a request, but that span is not set onc.Context()
. I suspect this simply is because there is a methodc.SetUserContext()
but noc.SetContext()
. The opentel package itself does not expose the context key in any way and so it is impossible to copy the value from one to the other. The opentel package follow the conical (to my knowledge) way of creating a newctx
var á lactx, err = SetThing(ctx)
, which is inherently incompatible with fiber'sc.Context()
.In other words, it is not possible to use
trace.Tracer.Start
with fiber'sc.Context()
, onlyc.UserContext()
.What can I do in this scenario?
The text was updated successfully, but these errors were encountered: