V2SpanConverter { public static zipkin2.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; } zipkin2.Endpoint.Builder builder = zipkin2.Endpoint.newBuilder(); if (peerIpv4 instanceof String) { builder.ip((String) peerIpv4); } if (peerPort instanceof Number) { builder.port(((Number) peerPort).intValue()); } if (peerService instanceof String) { builder.serviceName((String) peerService); } return builder.build(); }  static zipkin2.Span convertSpan(JaegerSpan span); static zipkin2.Endpoint extractPeerEndpoint(Map<String, Object> tags);  }
@Test public void testSpanDetectsEndpointTags() { String expectedIp = "127.0.0.1"; Integer 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, V2SpanConverter.extractPeerEndpoint(span.getTags()).ipv4()); assertEquals(expectedPort, V2SpanConverter.extractPeerEndpoint(span.getTags()).port()); assertEquals(expectedServiceName, V2SpanConverter.extractPeerEndpoint(span.getTags()).serviceName()); }