-
Notifications
You must be signed in to change notification settings - Fork 3.9k
core: install the binary logging client interceptor #3937
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
core: install the binary logging client interceptor #3937
Conversation
cc9eae0 to
1c23481
Compare
| @@ -0,0 +1,19 @@ | |||
| syntax = "proto3"; | |||
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.
Why was this file added? It seems unused.
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.
Oops removed
ejona86
left a comment
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.
Still a lot of reviewing left, but sending what I have now.
| .setIdempotent(idempotent) | ||
| .setSafe(safe) | ||
| .setSampledToLocalTracing(sampledToLocalTracing); | ||
| .setSampledToLocalTracing(sampledToLocalTracing) |
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.
Could you split this bug fix into a separate PR? We may want to backport it, for instance.
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.
Posted #3941, but I'll leave this part alone so the test can work.
| return new SimpleForwardingClientCall<ReqT, RespT>(next.newCall(method, callOptions)) { | ||
| @Override | ||
| public void start(Listener<RespT> responseListener, Metadata headers) { | ||
| spyListener = responseListener = |
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.
Why this change? I'm happy to kill a spy, but I don't see what it has to do with the rest of the PR.
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.
Restructuring of ForwardingClientCallListener and PartialForwardingClientCallListener broke the spy, probably because the method we want is now an inherited method.
This works but is less obvious than the non spy():
spy(new SimpleForwardingClientCallListener(responseListener) {
@Override
public void onHeaders(Metadata headers) {
super.onHeaders(headers);
}
});
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.
It is broken by PartialForwardingClientCallListener being package-private. Making it public fixes it. But it's also fixed if I bump mockito to 2.13.0.
If we use AdditionalAnswers.delegatesTo instead of spy (which is what we should do anywhere we use spy, really), then it starts working:
spyListener = responseListener =
mock(ClientCall.Listener.class,
delegatesTo(new SimpleForwardingClientCallListener(responseListener) {}));Although then it can be simplified to:
spyListener = responseListener =
mock(ClientCall.Listener.class, delegatesTo(responseListener));5b2137b to
5b02a65
Compare
|
Rebased against master, resolved conflicts. @ejona86 PTAL |
| * so the interceptor must be reusable across server calls. At runtime, the request and response | ||
| * types passed into the interceptor is always {@link java.io.InputStream}. | ||
| * so the interceptor must be reusable across calls. At runtime, the request and response | ||
| * marshallers are always {@code Marshaller<Inputstream>}. |
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.
s/stream/Stream/
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.
fixed
| private static final class IdentityMarshaller implements Marshaller<InputStream> { | ||
| @Override | ||
| public InputStream stream(InputStream value) { | ||
| return value; |
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.
Add a TODO to deal with retry?
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.
fixed
- TODO for retry - methods should be public, for later provider interface - fix capitalization typo
Some changes required to make this work:
MethodDescriptor.toBuilderso that it copies all fieldsBinaryLogProvider.providerreturnnullrather than the NullBinaryLogProvider. This is because on client side, the pipeline of interceptors is hard coded when the ManagedChannelImpl is created. It is desirable to avoid inserting a binary logging interceptor shim if we know there is no binary log.