{"action":"created","issue":{"url":"https://api.github.com/repos/grpc/grpc-java/issues/5019","repository_url":"https://api.github.com/repos/grpc/grpc-java","labels_url":"https://api.github.com/repos/grpc/grpc-java/issues/5019/labels{/name}","comments_url":"https://api.github.com/repos/grpc/grpc-java/issues/5019/comments","events_url":"https://api.github.com/repos/grpc/grpc-java/issues/5019/events","html_url":"https://github.com/grpc/grpc-java/issues/5019","id":375823971,"node_id":"MDU6SXNzdWUzNzU4MjM5NzE=","number":5019,"title":"Any way to get the Channel target through the channel and stub?","user":{"login":"yidongnan","id":3163314,"node_id":"MDQ6VXNlcjMxNjMzMTQ=","avatar_url":"https://avatars1.githubusercontent.com/u/3163314?v=4","gravatar_id":"","url":"https://api.github.com/users/yidongnan","html_url":"https://github.com/yidongnan","followers_url":"https://api.github.com/users/yidongnan/followers","following_url":"https://api.github.com/users/yidongnan/following{/other_user}","gists_url":"https://api.github.com/users/yidongnan/gists{/gist_id}","starred_url":"https://api.github.com/users/yidongnan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yidongnan/subscriptions","organizations_url":"https://api.github.com/users/yidongnan/orgs","repos_url":"https://api.github.com/users/yidongnan/repos","events_url":"https://api.github.com/users/yidongnan/events{/privacy}","received_events_url":"https://api.github.com/users/yidongnan/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-10-31T06:57:02Z","updated_at":"2018-10-31T13:55:09Z","closed_at":null,"author_association":"NONE","body":"### Is there any way to get the server name through the channel or stub or status\r\n\r\nWhen service-a calls service-b , if service-b goes down, It will get such an error , ``status.getCause()`` is .\r\n\r\n````java\r\nConnection refused: no further information: /127.0.0.1:9898\r\n````\r\n\r\nThrough the ``status`` object, we can see the ip and port of server (127.0.0.1:9898). \r\n\r\nThe ip and port is obtained by resolve the ``Channel`` target name of service-b through ``NameResolver``, \r\n\r\nBut I can't find any way to get the ``Channel`` target [ManagedChannelImpl.java#L123](https://github.com/grpc/grpc-java/blob/f3e371c7121a8d4d5e29186249648e8f095d078a/core/src/main/java/io/grpc/internal/ManagedChannelImpl.java#L123)  ( the target is my service-b instance name )  like ``channel.getTarget()`` or ``stub.getTarget()``  or ``status.getChannelTarget()`` etc..\r\n\r\nIs there any way to get the ``Channel`` target ?\r\n\r\n### What version of gRPC are you using?\r\n1.13.1\r\n\r\n### What did you expect to see?\r\n\r\nThe instance name of the server can be obtained in the status or channel or stub.\r\n\r\nIf I get the channel target, I will customize the log like this\r\n\r\n````text\r\nConnection refused: no further information: /127.0.0.1:9898 (service-b)\r\n````\r\n"},"comment":{"url":"https://api.github.com/repos/grpc/grpc-java/issues/comments/434695828","html_url":"https://github.com/grpc/grpc-java/issues/5019#issuecomment-434695828","issue_url":"https://api.github.com/repos/grpc/grpc-java/issues/5019","id":434695828,"node_id":"MDEyOklzc3VlQ29tbWVudDQzNDY5NTgyOA==","user":{"login":"ericgribkoff","id":5067076,"node_id":"MDQ6VXNlcjUwNjcwNzY=","avatar_url":"https://avatars2.githubusercontent.com/u/5067076?v=4","gravatar_id":"","url":"https://api.github.com/users/ericgribkoff","html_url":"https://github.com/ericgribkoff","followers_url":"https://api.github.com/users/ericgribkoff/followers","following_url":"https://api.github.com/users/ericgribkoff/following{/other_user}","gists_url":"https://api.github.com/users/ericgribkoff/gists{/gist_id}","starred_url":"https://api.github.com/users/ericgribkoff/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ericgribkoff/subscriptions","organizations_url":"https://api.github.com/users/ericgribkoff/orgs","repos_url":"https://api.github.com/users/ericgribkoff/repos","events_url":"https://api.github.com/users/ericgribkoff/events{/privacy}","received_events_url":"https://api.github.com/users/ericgribkoff/received_events","type":"User","site_admin":false},"created_at":"2018-10-31T13:55:09Z","updated_at":"2018-10-31T13:55:09Z","author_association":"CONTRIBUTOR","body":"I'm actually not sure how you are going from a gRPC `Status` instance to a `Channel` instance. I don't think we retain a channel reference anywhere inside of a status object. If you have custom error handling and are able to map status -> channel, could you also just map this to your original target string before name resolution? Otherwise, as far as I know, gRPC's [`Channel#authority`](https://grpc.io/grpc-java/javadoc/io/grpc/Channel.html#authority--) method is the only available API method related to what host a channel is connected to."}}
{"actor":{"display_login":"ericgribkoff"}}