mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2025-11-09 03:40:35 +08:00
Add context with request (#6824)
This commit is contained in:
@@ -127,8 +127,8 @@ func requestIDUnaryInterceptor() grpc.UnaryServerInterceptor {
|
||||
info *grpc.UnaryServerInfo,
|
||||
handler grpc.UnaryHandler,
|
||||
) (interface{}, error) {
|
||||
md, _ := metadata.FromIncomingContext(ctx)
|
||||
idList := md.Get(util.RequestIDKey)
|
||||
incomingMd, _ := metadata.FromIncomingContext(ctx)
|
||||
idList := incomingMd.Get(util.RequestIDKey)
|
||||
var reqID string
|
||||
if len(idList) > 0 {
|
||||
reqID = idList[0]
|
||||
@@ -137,6 +137,11 @@ func requestIDUnaryInterceptor() grpc.UnaryServerInterceptor {
|
||||
reqID = uuid.New().String()
|
||||
}
|
||||
|
||||
ctx = metadata.NewOutgoingContext(ctx,
|
||||
metadata.New(map[string]string{
|
||||
util.RequestIDKey: reqID,
|
||||
}))
|
||||
|
||||
ctx = util.WithRequestID(ctx, reqID)
|
||||
grpc.SetTrailer(ctx, metadata.Pairs(util.RequestIDKey, reqID))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user