-
Notifications
You must be signed in to change notification settings - Fork 9.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
etcdserver: add grpc interceptor to log info on incoming request to etcdserver #9990
Conversation
I don't see anywhere we use https://godoc.org/google.golang.org/grpc/peer#NewContext? Is peer information automatically embedded by middleware? |
@gyuho I think the peer information is been added during grpc remote call? Here is what I found:
|
@jingyih I see. Then, can you document those as a comment? Also, CIs are failing. |
@gyuho Sounds good! I will add the comment. |
@gyuho Regarding the failed CIs. Except for one go format issue, others seems to be caused by missing the grpc-middleware package in vendor. I saw there is scripts/updatedep.sh. Should I run this? Is there instructions on how to update the vendor? Thanks! |
@jingyih Yes, |
@gyuho After I ran updatedep.sh, I observed two changes to the Gopkg.lock file.
I am aware of the PR from you which upgraded gprc to v1.14.0 recently, so I did some investigation on the version downgrade. In master branch, I see that the grpc version is still v1.13.0 under folder https://github.com/coreos/etcd/tree/master/vendor/google.golang.org/ Is this consistent with the Gopkg.lock file which says the grpc version is v1.14.0? cc @jpbetz |
@jingyih Ah, previous godep run seemed to fail on that. Let me fix it shortly, to bump up gRPC to v1.14. |
I noticed that grpc moved transport package from their root folder to internal, in release 1.14.0 (https://github.com/grpc/grpc-go/releases/tag/v1.14.0) On the other hand, etcd does have dependency on "google.golang.org/grpc/transport". (in ./clientv3/integration/server_shutdown_test.go) Not sure if this is the reason grpc is v1.13.0 in etcd vendor folder. |
etcdserver/api/v3rpc/interceptor.go
Outdated
} | ||
var responseType string = info.FullMethod | ||
var reqCount, respCount int64 = 0, 0 | ||
var reqSize, respSize int = 0, 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need = 0, 0
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. They are zero-valued by default. Thanks!
etcd server To improve debuggability of etcd v3. 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. Uses zap logger if available, otherwise uses capnslog. Also did some clean up on the chaining of grpc interceptors on server side.
b898479
to
ca20f01
Compare
Rebased to master PR etcd-io#9994. Fixed a Go format issue in v3rpc/interceptor.go. Updated vendor to include go-grpc-middleware.
ca20f01
to
3066294
Compare
LGTM, I'll wait on @gyuho's approval for this one since I was involved in pre-review. |
etcdserver/api/v3rpc/interceptor.go
Outdated
@@ -90,7 +210,8 @@ func newStreamInterceptor(s *etcdserver.EtcdServer) grpc.StreamServerInterceptor | |||
} | |||
} | |||
|
|||
return prometheus.StreamServerInterceptor(srv, ss, info, handler) | |||
err := handler(srv, ss) | |||
return err |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can just simply return handler(srv, ss)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure I will make the change.
@jingyih Just small nits, then should be good to merge. Thanks! |
Code clean up in interceptor.go
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm thanks @jingyih !
…-origin-release-3.3 Automated cherry pick of #9990
…-origin-release-3.2-1534373481 etcdserver: cherry pick of #9990 to release-3.2
…lease-3.1 etcdserver: cherry pick of #9990 to release 3.1
/cc @wenjiaswe |
CHANGELOG-3.3: update from #9990
case *pb.PutResponse: | ||
_req, ok := req.(*pb.PutRequest) | ||
if ok { | ||
reqCount = 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This count is 1
for PUTs
, but 0
for other types of requests and not set for TXN
, what does this represent? Just trying to understand. Thanks. @jingyih
This is to improve debuggability of etcd v3. Added a grpc interceptor to log information on incoming requests to etcdserver.
The log output includes:
Example log output:
Logging is enable by --debug flag.
Fixes #9989
cc @jpbetz @gyuho