fix spans in UserContext() not connected properly to span from fiber.Ctx
This commit is contained in:
parent
86e9128c68
commit
031177f30c
@ -46,14 +46,15 @@ func Start(ctx context.Context, spanName string, opts ...trace.SpanStartOption)
|
|||||||
// NOTE: You can use [trace.WithAttributes] as a parameter to opts argument
|
// NOTE: You can use [trace.WithAttributes] as a parameter to opts argument
|
||||||
// Returns [c.UserContext] as [context.Context]
|
// Returns [c.UserContext] as [context.Context]
|
||||||
func FStart(c *fiber.Ctx, opts ...trace.SpanStartOption) (context.Context, trace.Span) {
|
func FStart(c *fiber.Ctx, opts ...trace.SpanStartOption) (context.Context, trace.Span) {
|
||||||
link := trace.LinkFromContext(fiberOpentelemetry.FromCtx(c))
|
span := trace.SpanFromContext(fiberOpentelemetry.FromCtx(c))
|
||||||
opts = append(opts, trace.WithLinks(link))
|
c.SetUserContext(trace.ContextWithSpan(c.UserContext(), span))
|
||||||
return fiberOpentelemetry.Tracer.Start(c.UserContext(), c.Method()+" "+c.Path(), opts...)
|
return fiberOpentelemetry.Tracer.Start(c.UserContext(), c.Method()+" "+c.Path(), opts...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Retrieve span using [fiber.Ctx]
|
// Retrieve span using [fiber.Ctx]
|
||||||
func SpanFromContext(c *fiber.Ctx) trace.Span {
|
func SpanFromContext(c *fiber.Ctx) trace.Span {
|
||||||
ctx := fiberOpentelemetry.FromCtx(c)
|
ctx := fiberOpentelemetry.FromCtx(c)
|
||||||
|
c.SetUserContext(trace.ContextWithSpan(c.UserContext(), trace.SpanFromContext(ctx)))
|
||||||
return trace.SpanFromContext(ctx)
|
return trace.SpanFromContext(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user