From 031177f30cffcdbd21faef695dafc15cef7145ba Mon Sep 17 00:00:00 2001 From: Natalia Goc Date: Mon, 20 May 2024 19:35:21 +0200 Subject: [PATCH] fix spans in UserContext() not connected properly to span from fiber.Ctx --- pkg/fiber_tracing/fiber_tracing.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/fiber_tracing/fiber_tracing.go b/pkg/fiber_tracing/fiber_tracing.go index 6503207..54daf12 100644 --- a/pkg/fiber_tracing/fiber_tracing.go +++ b/pkg/fiber_tracing/fiber_tracing.go @@ -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 // Returns [c.UserContext] as [context.Context] func FStart(c *fiber.Ctx, opts ...trace.SpanStartOption) (context.Context, trace.Span) { - link := trace.LinkFromContext(fiberOpentelemetry.FromCtx(c)) - opts = append(opts, trace.WithLinks(link)) + span := trace.SpanFromContext(fiberOpentelemetry.FromCtx(c)) + c.SetUserContext(trace.ContextWithSpan(c.UserContext(), span)) return fiberOpentelemetry.Tracer.Start(c.UserContext(), c.Method()+" "+c.Path(), opts...) } // Retrieve span using [fiber.Ctx] func SpanFromContext(c *fiber.Ctx) trace.Span { ctx := fiberOpentelemetry.FromCtx(c) + c.SetUserContext(trace.ContextWithSpan(c.UserContext(), trace.SpanFromContext(ctx))) return trace.SpanFromContext(ctx) }