PeerSpanDecorator implements SpanDecorator { @Override public void onRequest(final Span span, final RequestArguments arguments) { final URI uri = arguments.getRequestUri(); final int port = uri.getPort(); span.setTag(PEER_HOSTNAME, uri.getHost()); if (port == -1) { span.setTag(PEER_ADDRESS, uri.getHost()); } else { span.setTag(PEER_ADDRESS, uri.getHost() + ":" + port); span.setTag(PEER_PORT, port); } }  @Override void onRequest(final Span span, final RequestArguments arguments);  }
@Test void shouldIgnoreAbsentPort() { final MockTracer tracer = new MockTracer(); final MockSpan span = tracer.buildSpan("test").start(); final RequestArguments arguments = RequestArguments.create() .withBaseUrl(URI.create("http: .withUriTemplate("/test"); unit.onRequest(span, arguments); final Map<String, Object> tags = span.tags(); assertThat(tags, hasEntry("peer.hostname", "localhost")); assertThat(tags, hasEntry("peer.address", "localhost")); assertThat(tags, not(hasKey("peer.port"))); }