package global import ( "context" uuid "github.com/satori/go.uuid" "gogs.baozhida.cn/Cold_Logistic_libs/pkg/contrib/consts" "gogs.baozhida.cn/Cold_Logistic_libs/pkg/contrib/log" ) func MakeTraceCtx(ctx context.Context, keysAndValues ...interface{}) context.Context { requestId := uuid.NewV4().String() ctx = context.WithValue(ctx, consts.TraceIDHeader, requestId) keysAndValues = append([]interface{}{consts.TraceIDHeader, requestId}, keysAndValues...) ctxLog := log.WithValues(keysAndValues...) ctx = context.WithValue(ctx, log.GetContextKey(), ctxLog) return ctx }