Enable payload tracing for unary rpc
This commit is contained in:
19
server.go
19
server.go
@ -52,7 +52,7 @@ import (
|
|||||||
"google.golang.org/grpc/transport"
|
"google.golang.org/grpc/transport"
|
||||||
)
|
)
|
||||||
|
|
||||||
type methodHandler func(srv interface{}, ctx context.Context, codec Codec, buf []byte) (interface{}, error)
|
type methodHandler func(srv interface{}, ctx context.Context, decodeFunc func([]byte, interface{}) error, buf []byte) (interface{}, error)
|
||||||
|
|
||||||
// MethodDesc represents an RPC service's method specification.
|
// MethodDesc represents an RPC service's method specification.
|
||||||
type MethodDesc struct {
|
type MethodDesc struct {
|
||||||
@ -320,16 +320,25 @@ func (s *Server) processUnaryRPC(t transport.ServerTransport, stream *transport.
|
|||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if traceInfo.tr != nil {
|
//if traceInfo.tr != nil {
|
||||||
// TODO: set payload.msg to something that
|
// TODO: set payload.msg to something that
|
||||||
// prints usefully with %s; req is a []byte.
|
// prints usefully with %s; req is a []byte.
|
||||||
traceInfo.tr.LazyLog(&payload{sent: false}, true)
|
//traceInfo.tr.LazyLog(&payload{sent: false}, true)
|
||||||
}
|
//}
|
||||||
switch pf {
|
switch pf {
|
||||||
case compressionNone:
|
case compressionNone:
|
||||||
statusCode := codes.OK
|
statusCode := codes.OK
|
||||||
statusDesc := ""
|
statusDesc := ""
|
||||||
reply, appErr := md.Handler(srv.server, ctx, s.opts.codec, req)
|
df := func(b []byte, v interface{}) error {
|
||||||
|
if err := s.opts.codec.Unmarshal(b, v); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if traceInfo.tr != nil {
|
||||||
|
traceInfo.tr.LazyLog(&payload{sent: false, msg: v}, true)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
reply, appErr := md.Handler(srv.server, ctx, df, req)
|
||||||
if appErr != nil {
|
if appErr != nil {
|
||||||
if err, ok := appErr.(rpcError); ok {
|
if err, ok := appErr.(rpcError); ok {
|
||||||
statusCode = err.code
|
statusCode = err.code
|
||||||
|
Reference in New Issue
Block a user