I have enabled compression for a gRPC API, I want to verify if the response is getting compressed internally or not, Is there a way I can see the logs (trace logs) that the response is getting compressed?
I have used a custom unary interceptor but I am not able to see the logs.
`func loggingUnaryInterceptor(ctx goContext.Context, logger *log.LogWrapper) grpc.UnaryServerInterceptor {
return func(
ctx goContext.Context,
req interface{},
info *grpc.UnaryServerInfo,
handler grpc.UnaryHandler,
) (interface{}, error) {
start := time.Now()
p, ok := peer.FromContext(ctx)
if ok {
logger.Infow(ctx, "Request received",
zap.String("method", info.FullMethod),
zap.String("peer", p.Addr.String()),
)
}
md, ok := metadata.FromIncomingContext(ctx)
if ok {
enc := md.Get("grpc-encoding")
if len(enc) > 0 {
logger.Infow(ctx, "Request metadata", zap.String("compression", enc[0]))
} else {
logger.Infow(ctx, "Request metadata", zap.String("compression", "none"))
}
}
resp, err := handler(ctx, req)
duration := time.Since(start)
logger.Infow(ctx, "Request handled",
zap.String("method", info.FullMethod),
zap.Duration("duration", duration),
zap.String("peer", p.Addr.String()),
zap.Error(err),
)
return resp, err
}
}
`