MCPcopy Create free account
hub / github.com/grpc/grpc-java / getLabelValues

Method getLabelValues

netty/src/main/java/io/grpc/netty/TcpMetrics.java:197–226  ·  view source on GitHub ↗
(Channel channel)

Source from the content-addressed store, hash-verified

195 }
196
197 private static List<String> getLabelValues(Channel channel) {
198 String localAddress = "";
199 String localPort = "";
200 String peerAddress = "";
201 String peerPort = "";
202
203 SocketAddress local = channel.localAddress();
204 if (local instanceof InetSocketAddress) {
205 InetSocketAddress inetLocal = (InetSocketAddress) local;
206 if (inetLocal.getAddress() != null) {
207 localAddress = inetLocal.getAddress().getHostAddress();
208 } else if (inetLocal.getHostString() != null) {
209 localAddress = inetLocal.getHostString();
210 }
211 localPort = String.valueOf(inetLocal.getPort());
212 }
213
214 SocketAddress remote = channel.remoteAddress();
215 if (remote instanceof InetSocketAddress) {
216 InetSocketAddress inetRemote = (InetSocketAddress) remote;
217 if (inetRemote.getAddress() != null) {
218 peerAddress = inetRemote.getAddress().getHostAddress();
219 } else if (inetRemote.getHostString() != null) {
220 peerAddress = inetRemote.getHostString();
221 }
222 peerPort = String.valueOf(inetRemote.getPort());
223 }
224
225 return Arrays.asList(localAddress, localPort, peerAddress, peerPort);
226 }
227}

Callers 3

channelActiveMethod · 0.95
channelInactiveMethod · 0.95
recordTcpInfoMethod · 0.95

Calls 5

getAddressMethod · 0.80
asListMethod · 0.80
localAddressMethod · 0.45
getPortMethod · 0.45
remoteAddressMethod · 0.45

Tested by

no test coverage detected