diff --git a/client/dtmgrpc/dtmgimp/utils.go b/client/dtmgrpc/dtmgimp/utils.go index ac8f0a1..2bb6ba5 100644 --- a/client/dtmgrpc/dtmgimp/utils.go +++ b/client/dtmgrpc/dtmgimp/utils.go @@ -61,18 +61,18 @@ const dtmpre string = "dtm-" // TransInfo2Ctx add trans info to grpc context func TransInfo2Ctx(ctx context.Context, gid, transType, branchID, op, dtm string) context.Context { - md := metadata.Pairs( + nctx := ctx + if ctx == nil { + nctx = context.Background() + } + return metadata.AppendToOutgoingContext( + nctx, dtmpre+"gid", gid, dtmpre+"trans_type", transType, dtmpre+"branch_id", branchID, dtmpre+"op", op, dtmpre+"dtm", dtm, ) - nctx := ctx - if ctx == nil { - nctx = context.Background() - } - return metadata.NewOutgoingContext(nctx, md) } // Map2Kvs map to metadata kv