@@ -40,6 +40,7 @@ import (
40
40
"google.golang.org/grpc"
41
41
"google.golang.org/grpc/grpclog"
42
42
"google.golang.org/grpc/keepalive"
43
+ "google.golang.org/grpc/metadata"
43
44
44
45
pb "go.etcd.io/etcd/api/v3/etcdserverpb"
45
46
"go.etcd.io/etcd/client/pkg/v3/logutil"
@@ -422,6 +423,20 @@ func mustListenCMux(lg *zap.Logger, tlsinfo *transport.TLSInfo) cmux.CMux {
422
423
return cmux .New (l )
423
424
}
424
425
426
+ func contextPropagationUnaryServerInterceptor () grpc.UnaryServerInterceptor {
427
+ return func (
428
+ ctx context.Context ,
429
+ req interface {},
430
+ info * grpc.UnaryServerInfo ,
431
+ handler grpc.UnaryHandler ,
432
+ ) (interface {}, error ) {
433
+ if md , ok := metadata .FromIncomingContext (ctx ); ok {
434
+ ctx = metadata .NewOutgoingContext (ctx , md )
435
+ }
436
+ return handler (ctx , req )
437
+ }
438
+ }
439
+
425
440
func newGRPCProxyServer (lg * zap.Logger , client * clientv3.Client ) * grpc.Server {
426
441
if grpcProxyEnableOrdering {
427
442
vf := ordering .NewOrderViolationSwitchEndpointClosure (client )
@@ -467,6 +482,7 @@ func newGRPCProxyServer(lg *zap.Logger, client *clientv3.Client) *grpc.Server {
467
482
}
468
483
grpcChainUnaryList := []grpc.UnaryServerInterceptor {
469
484
grpc_prometheus .UnaryServerInterceptor ,
485
+ contextPropagationUnaryServerInterceptor (),
470
486
}
471
487
if grpcProxyEnableLogging {
472
488
grpcChainStreamList = append (grpcChainStreamList ,
0 commit comments