@@ -41,7 +41,7 @@ func StartNewGRPCServer(ctx context.Context, addr string, registerServerHook fun
41
41
}
42
42
43
43
// dapr/grpc service
44
- service , ok := daprd .NewServiceWithListener (listener , DefaultServerOptions ()... ).(* daprd.Server )
44
+ service , ok := daprd .NewServiceWithListener (listener , DefaultServerOptions (ctx )... ).(* daprd.Server )
45
45
if ! ok {
46
46
log .Fatal ().Msg ("dapr service listener is not a *daprd.Server" )
47
47
}
@@ -87,10 +87,13 @@ func StartNewGRPCServer(ctx context.Context, addr string, registerServerHook fun
87
87
// DefaultUnaryInterceptors returns the slice of default interceptors for unary gRPC calls
88
88
//
89
89
// 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 {
91
94
return []grpc.UnaryServerInterceptor {
92
95
metrics .UnaryServerInterceptor (),
93
- hwgrpc .UnaryPanicRecoverInterceptor (),
96
+ hwgrpc .UnaryPanicRecoverInterceptor (ctx ),
94
97
hwgrpc .UnaryLoggingInterceptor ,
95
98
hwgrpc .UnaryErrorQualityControlInterceptor ,
96
99
hwgrpc .UnaryLocaleInterceptor ,
@@ -104,10 +107,13 @@ func DefaultUnaryInterceptors(metrics *prometheusGrpcProvider.ServerMetrics) []g
104
107
// DefaultStreamInterceptors returns the slice of default interceptors for stream gRPC calls
105
108
//
106
109
// 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 {
108
114
return []grpc.StreamServerInterceptor {
109
115
metrics .StreamServerInterceptor (),
110
- hwgrpc .StreamPanicRecoverInterceptor (),
116
+ hwgrpc .StreamPanicRecoverInterceptor (ctx ),
111
117
hwgrpc .StreamLoggingInterceptor ,
112
118
hwgrpc .StreamErrorQualityControlInterceptor ,
113
119
hwgrpc .StreamLocaleInterceptor ,
@@ -118,16 +124,14 @@ func DefaultStreamInterceptors(metrics *prometheusGrpcProvider.ServerMetrics) []
118
124
}
119
125
}
120
126
121
- func DefaultServerOptions () []grpc.ServerOption {
127
+ func DefaultServerOptions (ctx context. Context ) []grpc.ServerOption {
122
128
// register new metrics collector with prometheus
123
129
metrics := prometheusGrpcProvider .NewServerMetrics ()
124
130
125
- if ! hwutil .IsRunningInGoTests () {
126
- telemetry .PrometheusRegistry ().MustRegister (metrics )
127
- }
131
+ telemetry .PrometheusRegistry (ctx ).MustRegister (metrics )
128
132
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 )... )
131
135
statsHandler := grpc .StatsHandler (otelgrpc .NewServerHandler ())
132
136
133
137
return []grpc.ServerOption {unaryInterceptorChain , streamInterceptorChain , statsHandler }
0 commit comments