SelectSpansAndAnnotations implements Function<DSLContext, List<Span>> { static Endpoint endpoint(Record a) { Endpoint.Builder result = Endpoint.newBuilder() .serviceName(a.getValue(ZIPKIN_ANNOTATIONS.ENDPOINT_SERVICE_NAME)) .port(Schema.maybeGet(a, ZIPKIN_ANNOTATIONS.ENDPOINT_PORT, (short) 0)); int ipv4 = maybeGet(a, ZIPKIN_ANNOTATIONS.ENDPOINT_IPV4, 0); if (ipv4 != 0) { result.parseIp( new byte[] { (byte) (ipv4 >> 24 & 0xff), (byte) (ipv4 >> 16 & 0xff), (byte) (ipv4 >> 8 & 0xff), (byte) (ipv4 & 0xff) }); } result.parseIp(Schema.maybeGet(a, ZIPKIN_ANNOTATIONS.ENDPOINT_IPV6, null)); return result.build(); } SelectSpansAndAnnotations(Schema schema); @Override List<Span> apply(DSLContext context);  }
@Test public void endpoint_justIpv4() { Record4<String, Integer, Short, byte[]> endpointRecord = endpointRecord("", 127 << 24 | 1, (short) 0, new byte[0]); assertThat(SelectSpansAndAnnotations.endpoint(endpointRecord)) .isEqualTo(Endpoint.newBuilder().ip("127.0.0.1").build()); }