mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
etcdserver: add grpc interceptor to log info on incoming request to
etcdserver To improve debuggability of etcd v3.1. Added a grpc interceptor to log info on incoming requests to etcd server. The log output includes remote client info, request content (with value field redacted), request handling latency, response size, etc. Dependency on zap logger and grpc_middleware is removed during backporting. Added checking in logging interceptor. If debug level is disabled, skip logUnaryRequestStats() to avoid potential performance degradation. (PR #10021)
This commit is contained in:
parent
4855ca62b5
commit
dd2803c4a6
@ -93,7 +93,7 @@ func logUnaryRequestStats(ctx context.Context, info *grpc.UnaryServerInfo, start
|
||||
reqContent = _req.String()
|
||||
}
|
||||
if _resp != nil {
|
||||
respCount = _resp.GetCount()
|
||||
respCount = _resp.Count
|
||||
respSize = _resp.Size()
|
||||
}
|
||||
case *pb.PutResponse:
|
||||
@ -116,13 +116,13 @@ func logUnaryRequestStats(ctx context.Context, info *grpc.UnaryServerInfo, start
|
||||
reqContent = _req.String()
|
||||
}
|
||||
if _resp != nil {
|
||||
respCount = _resp.GetDeleted()
|
||||
respCount = _resp.Deleted
|
||||
respSize = _resp.Size()
|
||||
}
|
||||
case *pb.TxnResponse:
|
||||
_req, ok := req.(*pb.TxnRequest)
|
||||
if ok && _resp != nil {
|
||||
if _resp.GetSucceeded() { // determine the 'actual' count and size of request based on success or failure
|
||||
if _resp.Succeeded { // determine the 'actual' count and size of request based on success or failure
|
||||
reqCount = int64(len(_req.GetSuccess()))
|
||||
reqSize = 0
|
||||
for _, r := range _req.GetSuccess() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user