ThriftSpanConverter { public static Endpoint extractPeerEndpoint(Map<String, Object> tags) { Object peerIpv4 = tags.get(Tags.PEER_HOST_IPV4.getKey()); Object peerPort = tags.get(Tags.PEER_PORT.getKey()); Object peerService = tags.get(Tags.PEER_SERVICE.getKey()); if (peerIpv4 == null && peerPort == null && peerService == null) { return null; } Endpoint peerEndpoint = new Endpoint(0, (short) 0, ""); if (peerIpv4 instanceof Integer) { peerEndpoint.setIpv4((Integer) peerIpv4); } if (peerPort instanceof Number) { peerEndpoint.setPort(((Number)peerPort).shortValue()); } if (peerService instanceof String) { peerEndpoint.setService_name((String) peerService); } return peerEndpoint; }  static com.twitter.zipkin.thriftjava.Span convertSpan(JaegerSpan jaegerSpan); static Endpoint extractPeerEndpoint(Map<String, Object> tags);  }
@Test public void testSpanDetectsEndpointTags() { int expectedIp = (127 << 24) | 1; int expectedPort = 8080; String expectedServiceName = "some-peer-service"; JaegerSpan span = tracer.buildSpan("test-service-operation").start(); Tags.PEER_HOST_IPV4.set(span, expectedIp); Tags.PEER_PORT.set(span, expectedPort); Tags.PEER_SERVICE.set(span, expectedServiceName); assertEquals(expectedIp, ThriftSpanConverter.extractPeerEndpoint(span.getTags()).getIpv4()); assertEquals(expectedPort, ThriftSpanConverter.extractPeerEndpoint(span.getTags()).getPort()); assertEquals(expectedServiceName, ThriftSpanConverter.extractPeerEndpoint(span.getTags()).getService_name()); }