Skip to content

Commit

Permalink
use protosanitizer for logging gRPC requests/responces
Browse files Browse the repository at this point in the history
protosanitizer supports suppressing secrets while logging gRPC messages.

Signed-off-by: Amarnath Valluri <amarnath.valluri@intel.com>
  • Loading branch information
avalluri committed Mar 1, 2019
1 parent d24d610 commit 5ea6caf
Show file tree
Hide file tree
Showing 8 changed files with 690 additions and 5 deletions.
12 changes: 11 additions & 1 deletion Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions pkg/pmem-common/tracing.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
// "fmt"
"io"

"github.com/kubernetes-csi/csi-lib-utils/protosanitizer"
"golang.org/x/net/context"
"google.golang.org/grpc"
"k8s.io/klog/glog"
Expand All @@ -26,25 +27,25 @@ import (
// the secrets.
func LogGRPCServer(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) {
glog.V(3).Infof("GRPC call: %s", info.FullMethod)
glog.V(5).Infof("GRPC request: %+v", req)
glog.V(5).Infof("GRPC request: %+v", protosanitizer.StripSecrets(req))
resp, err := handler(ctx, req)
if err != nil {
glog.Errorf("GRPC error: %v", err)
} else {
glog.V(5).Infof("GRPC response: %+v", resp)
glog.V(5).Infof("GRPC response: %+v", protosanitizer.StripSecrets(resp))
}
return resp, err
}

// LogGRPCClient does the same as LogGRPCServer, only on the client side.
func LogGRPCClient(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error {
glog.V(3).Infof("GRPC call: %s", method)
glog.V(5).Infof("GRPC request: %+v", req)
glog.V(5).Infof("GRPC request: %+v", protosanitizer.StripSecrets(req))
err := invoker(ctx, method, req, reply, cc, opts...)
if err != nil {
glog.Errorf("GRPC error: %v", err)
} else {
glog.V(5).Infof("GRPC response: %+v", reply)
glog.V(5).Infof("GRPC response: %+v", protosanitizer.StripSecrets(reply))
}
return err
}
Expand Down
1 change: 1 addition & 0 deletions runtime-deps.csv
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Go,https://github.com/golang/go
github.com/kubernetes-csi/csi-lib-utils
golang-protobuf,https://github.com/golang/protobuf
google uuid,https://github.com/google/uuid
grpc-go,https://github.com/grpc/grpc-go
Expand Down
1 change: 1 addition & 0 deletions vendor-bom.csv
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ github.com/imdario/mergo;mergo;BSD 3-clause "New" or "Revised" License
github.com/inconshreveable/mousetrap;inconshreveable mousetrap;Apache License 2.0
github.com/json-iterator/go;json-iterator go;MIT License
github.com/konsorten/go-windows-terminal-sequences;go-windows-terminal-sequences;MIT License
github.com/kubernetes-csi/csi-lib-utils;csi-lib-utils;Apache License 2.0
github.com/kubernetes-csi/csi-test;Kubernetes-CSI csi-test;Apache License 2.0
github.com/mailru/easyjson;Mail.Ru easyjson for golag;MIT License
github.com/matttproud/golang_protobuf_extensions;Matt Proud golang-protobuf-extentions;Apache License 2.0
Expand Down
93 changes: 93 additions & 0 deletions vendor/github.com/golang/protobuf/descriptor/descriptor.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

201 changes: 201 additions & 0 deletions vendor/github.com/kubernetes-csi/csi-lib-utils/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 5ea6caf

Please sign in to comment.