Skip to content

Commit

Permalink
fix(grpc): Chain interceptor (#296)
Browse files Browse the repository at this point in the history
* fix(grpc): Chain interceptor

* fix(grpc): Chain interceptor

* fix(grpc): Chain interceptor
  • Loading branch information
samcm committed Apr 8, 2024
1 parent fdcc570 commit 59711a6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 2 additions & 4 deletions pkg/output/xatu/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,8 @@ type ItemExporter struct {

func NewItemExporter(name string, config *Config, log logrus.FieldLogger) (ItemExporter, error) {
opts := []grpc.DialOption{
grpc.WithUnaryInterceptor(grpc_prometheus.UnaryClientInterceptor),
grpc.WithStreamInterceptor(grpc_prometheus.StreamClientInterceptor),
grpc.WithStreamInterceptor(retry.StreamClientInterceptor()),
grpc.WithUnaryInterceptor(retry.UnaryClientInterceptor()),
grpc.WithChainUnaryInterceptor(grpc_prometheus.UnaryClientInterceptor, retry.UnaryClientInterceptor()),
grpc.WithChainStreamInterceptor(grpc_prometheus.StreamClientInterceptor, retry.StreamClientInterceptor()),
}

if config.TLS {
Expand Down
6 changes: 4 additions & 2 deletions pkg/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,6 @@ func (x *Xatu) startGrpcServer(ctx context.Context) error {
grpc_prometheus.EnableHandlingTimeHistogram()

opts := []grpc.ServerOption{
grpc.StreamInterceptor(grpc_prometheus.StreamServerInterceptor),
grpc.UnaryInterceptor(grpc_prometheus.UnaryServerInterceptor),
grpc.MaxRecvMsgSize(mb100),
grpc.KeepaliveParams(keepalive.ServerParameters{
MaxConnectionIdle: 5 * time.Minute,
Expand All @@ -237,7 +235,11 @@ func (x *Xatu) startGrpcServer(ctx context.Context) error {
Time: 1 * time.Minute,
Timeout: 15 * time.Second,
}),
grpc.ChainStreamInterceptor(
grpc.StreamServerInterceptor(grpc_prometheus.StreamServerInterceptor),
),
grpc.ChainUnaryInterceptor(
grpc.UnaryServerInterceptor(grpc_prometheus.UnaryServerInterceptor),
func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) {
resp, err := handler(ctx, req)
if err != nil {
Expand Down

0 comments on commit 59711a6

Please sign in to comment.