TracingHttpAsyncClientBuilder extends HttpAsyncClientBuilder { static void parseTargetAddress(HttpHost target, Span span) { if (span.isNoop()) return; if (target == null) return; InetAddress address = target.getAddress(); if (address != null) { if (span.remoteIpAndPort(address.getHostAddress(), target.getPort())) return; } span.remoteIpAndPort(target.getHostName(), target.getPort()); } TracingHttpAsyncClientBuilder(HttpTracing httpTracing); static HttpAsyncClientBuilder create(Tracing tracing); static HttpAsyncClientBuilder create(HttpTracing httpTracing); @Override CloseableHttpAsyncClient build();  }
@Test public void parseTargetAddress_skipsOnNoop() { when(span.isNoop()).thenReturn(true); TracingHttpAsyncClientBuilder.parseTargetAddress(null, span); verify(span).isNoop(); verifyNoMoreInteractions(span); }
@Test public void parseTargetAddress_prefersAddress() throws UnknownHostException { when(span.isNoop()).thenReturn(false); when(span.remoteIpAndPort("1.2.3.4", -1)).thenReturn(true); HttpHost host = new HttpHost(InetAddress.getByName("1.2.3.4"), "3.4.5.6", -1, "http"); TracingHttpAsyncClientBuilder.parseTargetAddress(host, span); verify(span).isNoop(); verify(span).remoteIpAndPort("1.2.3.4", -1); verifyNoMoreInteractions(span); }
@Test public void parseTargetAddress_acceptsHostname() { when(span.isNoop()).thenReturn(false); HttpHost host = new HttpHost("1.2.3.4"); TracingHttpAsyncClientBuilder.parseTargetAddress(host, span); verify(span).isNoop(); verify(span).remoteIpAndPort("1.2.3.4", -1); verifyNoMoreInteractions(span); }
@Test public void parseTargetAddress_IpAndPortFromHost() { when(span.isNoop()).thenReturn(false); when(span.remoteIpAndPort("1.2.3.4", 9999)).thenReturn(true); HttpHost host = new HttpHost("1.2.3.4", 9999); TracingHttpAsyncClientBuilder.parseTargetAddress(host, span); verify(span).isNoop(); verify(span).remoteIpAndPort("1.2.3.4", 9999); verifyNoMoreInteractions(span); }