请求开始时间设置为毫秒

This commit is contained in:
白茶清欢 2022-01-13 21:59:06 +08:00
parent 409120f77d
commit 940d9f327e

View File

@ -28,7 +28,7 @@ func InitRequest(startTimeField string, traceIDField string) gin.HandlerFunc {
if len(traceIDField) == 0 { if len(traceIDField) == 0 {
traceIDField = "trace_id" traceIDField = "trace_id"
} }
ctx.Set(startTimeField, time.Now().Unix()) ctx.Set(startTimeField, time.Now().UnixMilli())
// 设置请求trace_id // 设置请求trace_id
ctx.Set(traceIDField, commonUtil.GetHostIP()+"-"+ctx.ClientIP()+"-"+time.Now().Format("20060102150405")+"-"+commonUtil.Md5(commonUtil.GenRandomString("", 16))) ctx.Set(traceIDField, commonUtil.GetHostIP()+"-"+ctx.ClientIP()+"-"+time.Now().Format("20060102150405")+"-"+commonUtil.Md5(commonUtil.GenRandomString("", 16)))
ctx.Next() ctx.Next()