@@ -41,7 +41,7 @@ func StartNewGRPCServer(ctx context.Context, addr string, registerServerHook fun
4141 }
4242
4343 // dapr/grpc service
44- service , ok := daprd .NewServiceWithListener (listener , DefaultServerOptions ()... ).(* daprd.Server )
44+ service , ok := daprd .NewServiceWithListener (listener , DefaultServerOptions (ctx )... ).(* daprd.Server )
4545 if ! ok {
4646 log .Fatal ().Msg ("dapr service listener is not a *daprd.Server" )
4747 }
@@ -87,10 +87,13 @@ func StartNewGRPCServer(ctx context.Context, addr string, registerServerHook fun
8787// DefaultUnaryInterceptors returns the slice of default interceptors for unary gRPC calls
8888//
8989// chain := grpc.ChainUnaryInterceptor(common.DefaultUnaryInterceptors()...)
90- func DefaultUnaryInterceptors (metrics * prometheusGrpcProvider.ServerMetrics ) []grpc.UnaryServerInterceptor {
90+ func DefaultUnaryInterceptors (
91+ ctx context.Context ,
92+ metrics * prometheusGrpcProvider.ServerMetrics ,
93+ ) []grpc.UnaryServerInterceptor {
9194 return []grpc.UnaryServerInterceptor {
9295 metrics .UnaryServerInterceptor (),
93- hwgrpc .UnaryPanicRecoverInterceptor (),
96+ hwgrpc .UnaryPanicRecoverInterceptor (ctx ),
9497 hwgrpc .UnaryLoggingInterceptor ,
9598 hwgrpc .UnaryErrorQualityControlInterceptor ,
9699 hwgrpc .UnaryLocaleInterceptor ,
@@ -104,10 +107,13 @@ func DefaultUnaryInterceptors(metrics *prometheusGrpcProvider.ServerMetrics) []g
104107// DefaultStreamInterceptors returns the slice of default interceptors for stream gRPC calls
105108//
106109// chain := grpc.ChainStreamInterceptor(common.DefaultStreamInterceptors()...)
107- func DefaultStreamInterceptors (metrics * prometheusGrpcProvider.ServerMetrics ) []grpc.StreamServerInterceptor {
110+ func DefaultStreamInterceptors (
111+ ctx context.Context ,
112+ metrics * prometheusGrpcProvider.ServerMetrics ,
113+ ) []grpc.StreamServerInterceptor {
108114 return []grpc.StreamServerInterceptor {
109115 metrics .StreamServerInterceptor (),
110- hwgrpc .StreamPanicRecoverInterceptor (),
116+ hwgrpc .StreamPanicRecoverInterceptor (ctx ),
111117 hwgrpc .StreamLoggingInterceptor ,
112118 hwgrpc .StreamErrorQualityControlInterceptor ,
113119 hwgrpc .StreamLocaleInterceptor ,
@@ -118,16 +124,14 @@ func DefaultStreamInterceptors(metrics *prometheusGrpcProvider.ServerMetrics) []
118124 }
119125}
120126
121- func DefaultServerOptions () []grpc.ServerOption {
127+ func DefaultServerOptions (ctx context. Context ) []grpc.ServerOption {
122128 // register new metrics collector with prometheus
123129 metrics := prometheusGrpcProvider .NewServerMetrics ()
124130
125- if ! hwutil .IsRunningInGoTests () {
126- telemetry .PrometheusRegistry ().MustRegister (metrics )
127- }
131+ telemetry .PrometheusRegistry (ctx ).MustRegister (metrics )
128132
129- unaryInterceptorChain := grpc .ChainUnaryInterceptor (DefaultUnaryInterceptors (metrics )... )
130- streamInterceptorChain := grpc .ChainStreamInterceptor (DefaultStreamInterceptors (metrics )... )
133+ unaryInterceptorChain := grpc .ChainUnaryInterceptor (DefaultUnaryInterceptors (ctx , metrics )... )
134+ streamInterceptorChain := grpc .ChainStreamInterceptor (DefaultStreamInterceptors (ctx , metrics )... )
131135 statsHandler := grpc .StatsHandler (otelgrpc .NewServerHandler ())
132136
133137 return []grpc.ServerOption {unaryInterceptorChain , streamInterceptorChain , statsHandler }
0 commit comments