Skip to content

Commit

Permalink
contrib/gofiber/fiber.v2: use UserContext in Middleware for span crea…
Browse files Browse the repository at this point in the history
…tion

The Middleware was incorrectly using `c.Context()` instead of `c.UserContext()`
to start spans. This could break the propagation of the context defined by other
middlewares earlier in the chain.

This change ensures that `tracer.StartSpanFromContext` uses the correct context
provided by Fiber, preserving context propagation and ensuring proper tracing behavior.

Fixes DataDog#2199
  • Loading branch information
tonyduburque committed Dec 12, 2024
1 parent 6004a6c commit 8a2662b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion contrib/gofiber/fiber.v2/fiber.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func Middleware(opts ...Option) func(c *fiber.Ctx) error {
tracer.Tag(ext.Component, componentName),
tracer.Tag(ext.SpanKind, ext.SpanKindServer),
)
span, ctx := tracer.StartSpanFromContext(c.Context(), cfg.spanName, opts...)
span, ctx := tracer.StartSpanFromContext(c.UserContext(), cfg.spanName, opts...)

defer span.Finish()

Expand Down

0 comments on commit 8a2662b

Please sign in to comment.