package middlewares import ( "github.com/gin-gonic/gin" "qteam/app/http/trace" "qteam/app/utils" "strconv" ) const ( componentIDGOHttpServer = 5004 ) func Trace() gin.HandlerFunc { return func(c *gin.Context) { tracer, err := trace.Tracer() if err != nil { utils.Log(c, "trace err", err) } span := tracer.StartSpan("base trace") // 可以自定义tag span.SetName(c.Request.RequestURI) span.Tag("methd", c.Request.Method) c.Request = c.Request.WithContext(c) c.Next() code := c.Writer.Status() span.Tag("status", strconv.Itoa(code)) span.Finish() } }