Commit a8d0809d authored by hujiebin's avatar hujiebin

feat:补上traceId

parent b4d52c16
......@@ -90,7 +90,7 @@ func LoggerHandle(c *gin.Context) {
start := time.Now()
clientIp := c.ClientIP()
method := c.Request.Method
traceId := genTraceId()
traceId := genTraceId(c)
reqUri := c.Request.RequestURI
c.Set(mycontext.TRACEID, traceId)
//
......
package route
import (
"git.hilo.cn/hilo-common/mycontext"
"github.com/gin-gonic/gin"
uuid "github.com/satori/go.uuid"
"strings"
)
func genTraceId() string {
func genTraceId(c *gin.Context) string {
if trace := c.GetHeader(mycontext.TRACEID); len(trace) > 0 {
return trace
}
traceId := strings.Replace(uuid.NewV4().String(), "-", "", -1)
traceId = traceId[:len(traceId)/2]
return traceId
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment