[BUG] fiber app may not shutdown gracefully when using dd-trace-go/contrib/gofiber/fiber.v2/fiber.go middleware #2199
Labels
apm:ecosystem
contrib/* related feature requests or bugs
bug
unintended behavior that has to be fixed
I'm not sure this is a bug or intended.
Version of dd-trace-go
1.56.1
Describe what happened:
after calling
Middleware
function,c.UserContext()
returns*fasthttp.RequestCtx
which carries a deadline a cancellation signal.(https://github.com/gofiber/fiber/blob/master/ctx.go#L443)Describe what you expected:
Middleware
function should not mutate the returned context ofc.UserContext()
, which meansc.UserContext()
should not have any deadline or cancellation signals if not set previously.Steps to reproduce the issue:
suppose there are 2 servers; s1(localhost:3000), s2(localhost:8080), and s1 sends GET request to s2.
s1 needs to shutdown gracefully. s1 uses
Middleware
function as below.server 1 (s1)
server 2 (s2)
when sending SIGTERM to s1 during s1 is handling requests, s1 shutdowns immediately, which does not when s1 without
Middleware
function.Additional environment details (Version of Go, Operating System, etc.):
Go 1.21.x
Proposal
use
c.UserContext()
(https://github.com/gofiber/fiber/blob/master/ctx.go#L451) instead ofc.Context()
(type*fasthttp.RequestCtx
) when start span as below.This matches with other framework's
Middleware
function...net/http
https://github.com/DataDog/dd-trace-go/blob/main/contrib/net/http/trace.go#L66
https://github.com/DataDog/dd-trace-go/blob/main/contrib/internal/httptrace/httptrace.go#L61
https://github.com/golang/go/blob/master/src/net/http/request.go#L346
gin
https://github.com/DataDog/dd-trace-go/blob/main/contrib/gin-gonic/gin/gintrace.go#L53
https://github.com/DataDog/dd-trace-go/blob/main/contrib/internal/httptrace/httptrace.go#L61
.. (same as net/http)
go-chi
https://github.com/DataDog/dd-trace-go/blob/main/contrib/go-chi/chi/chi.go#L54
https://github.com/DataDog/dd-trace-go/blob/main/contrib/internal/httptrace/httptrace.go#L61
.. (same as net/http)
The text was updated successfully, but these errors were encountered: