question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

getAttributes() always empty if called from SimpleForwardingClientCall

See original GitHub issue

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:

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) {
        log.info("grpc request; method: {}, attributes: {}", method.getFullMethodName(),
            getAttributes());

        super.start(responseListener, headers);
      }
    };
  }
}

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.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
dapengzhang0commented, Feb 27, 2018

+1

Do you happen to be using plaintext?

@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: Grpc.TRANSPORT_ATTR_SSL_SESSION and Grpc.TRANSPORT_ATTR_REMOTE_ADDR

0reactions
maseevcommented, Feb 28, 2018

Oh, I didn’t know that. I do use plaintext actually. I guess that explains everything. Thank you for your help @zpencer @dapengzhang0.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ForwardingClientCall.SimpleForwardingClientCall (grpc-all ...
Method Summary ; Attributes · getAttributes(). Returns additional properties of the call. ; void, halfClose(). Close the call for request message sending.
Read more >
Index (grpc-all 1.25.0 API) - javadoc.io
Returns mutable services registered with the server, or an empty list if not supported by the implementation. getName() - Method in class io.grpc.inprocess....
Read more >
Diff - platform/external/grpc-grpc-java - Google Git
+ + // targetName is the server service account name for secure name checking. ... + @Attr public Attributes getAttributes() { return attrs;...
Read more >
io.grpc.DecompressorRegistry Example - Program Talk
NONE; } } // Always put compressor, even if it's idenreplacedy. ... @Test public void getAttributes() { ClientCallImpl<Void, Void> call = new ...
Read more >
io.grpc.ForwardingClientCall.SimpleForwardingClientCall
This page shows Java code examples of io.grpc. ... return new SimpleForwardingClientCall<ReqT, RespT>(call) { @Override public void start(Listener<RespT> ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found