allow retrieving spans from fiber.Ctx
This commit is contained in:
parent
77ab12c3ac
commit
372f4367ed
@ -39,6 +39,12 @@ func main() {
|
||||
}))
|
||||
defer tracing.ShutdownTracer()
|
||||
|
||||
main.Use(func(c *fiber.Ctx) error {
|
||||
span := tracing.SpanFromContext(c)
|
||||
span.AddEvent("pushed into a span an event from middleware")
|
||||
return c.Next()
|
||||
})
|
||||
|
||||
main.Get("/", Handler)
|
||||
|
||||
// handle interrupts (shutdown)
|
||||
|
@ -49,6 +49,12 @@ func FStart(c *fiber.Ctx, opts ...trace.SpanStartOption) (context.Context, trace
|
||||
return fiberOpentelemetry.Tracer.Start(ctx, c.Method()+" "+c.Path(), opts...)
|
||||
}
|
||||
|
||||
// Retrieve span using [fiber.Ctx]
|
||||
func SpanFromContext(c *fiber.Ctx) trace.Span {
|
||||
ctx := fiberOpentelemetry.FromCtx(c)
|
||||
return trace.SpanFromContext(ctx)
|
||||
}
|
||||
|
||||
func NewMiddleware(config Config) func(*fiber.Ctx) error {
|
||||
var tracerProviders []trc.TracerProviderOption
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user