-
Notifications
You must be signed in to change notification settings - Fork 3.9k
getAttributes() always empty if called from SimpleForwardingClientCall #4118
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
Comments
You seems to call |
Yes, you're right. According to the javadoc, the class LoggingClientInterceptor implements ClientInterceptor {
private static final Logger log = LoggerFactory.getLogger(LoggingClientInterceptor.class);
@Override
public <ReqT, RespT> ClientCall<ReqT, RespT> interceptCall(MethodDescriptor<ReqT, RespT> method,
CallOptions callOptions, Channel next) {
return new SimpleForwardingClientCall<ReqT, RespT>(next.newCall(method, callOptions)) {
@Override
public void start(Listener<RespT> responseListener, Metadata headers) {
final SimpleForwardingClientCallListener<RespT> listener =
new SimpleForwardingClientCallListener<RespT>(responseListener) {
@Override
public void onMessage(RespT response) {
log.debug("grpc response; method: {}, attributes: {}, response: {}",
method.getFullMethodName(), getAttributes(), response);
super.onMessage(response);
}
};
super.start(listener, headers);
}
@Override
public void sendMessage(ReqT request) {
log.debug("grpc request; method: {}, request: {}", method.getFullMethodName(), request);
super.sendMessage(request);
}
};
}
} And again, I get the empty set of attributes when I call
So, it should be pretty safe to call the |
@maseev , what attribute are you expecting? What transport are you using: Netty, OkHttp, or InProcess? |
@dapengzhang0 I'm expecting an attribute which contains the information about the server to which the client is going to send a request. I'm using the Netty transport. |
Do you happen to be using plaintext? |
+1
@maseev, your updated interceptor will work correctly. But if you are using plaintext, no attributes will be added by the grpc library. If you are using Netty transport with TLS, two attributes may be added: |
Oh, I didn't know that. I do use |
What version of gRPC are you using?
1.10.0
What did you expect to see?
Let's say we have the following client interceptor which is attached to our channel:
When calling the
getAttributes()
method I expected to see a set of attributes which contains at least the information about the server to which the client is going to make a request to. Unfortunately,getAttributes()
method always empty.The text was updated successfully, but these errors were encountered: