gin-gonic / gin

Gin is a HTTP web framework written in Go (Golang). It features a Martini-like API with much better performance -- up to 40 times faster. If you need smashing performance, get yourself some Gin.
https://gin-gonic.com/
MIT License
76.67k stars 7.91k forks source link

gin context with tracing not work #3993

Open pepea23 opened 2 weeks ago

pepea23 commented 2 weeks ago

when implementing use otel tracing like this image

and apply to router like "router.POST("/v4/*xxxx", gatewayPostHandler, WithTracer())"

then tried to get a trace I found that gin context does not save trace id and span id it empty so how to reproduce the problem?

handler function image trace_id and span_id is empty

GetTraceIds function image

Environment

FarmerChillax commented 2 weeks ago

problem locating the hasRequestContext function return Falsehttps://github.com/gin-gonic/gin/blob/9c081de9cdd1948f521d47d170d18cbc2981c33a/context.go#L1240

It seems that the problem is caused by the ContextWithFallback field, but I am not sure what this field does.