private static Endpoint to(zipkin2.Endpoint host) { if (host == null) return null; byte[] ipv4 = host.ipv4Bytes(); return Endpoint.builder() .ipv4(ipv4 != null ? ByteBuffer.wrap(ipv4).getInt() : 0) .ipv6(host.ipv6Bytes()) .port(host.portAsInt()) .serviceName(host.serviceName()).build(); }
/** * Like {@link #setClientSent()}, except you can log the network context of the destination. * * @param ipv4 ipv4 of the server as an int. Ex for 1.2.3.4, it would be (1 << 24) | (2 << 16) | (3 << 8) | 4 * @param port listen port the client is connecting to, or 0 if unknown * @param serviceName lowercase {@link Endpoint#service_name name} of the service being called * or null if unknown * * @deprecated use {@link #setClientSent(Endpoint)} */ @Deprecated public void setClientSent(int ipv4, int port, @Nullable String serviceName) { if (serviceName == null) serviceName = "unknown"; setClientSent(Endpoint.builder().ipv4(ipv4).port(port).serviceName(serviceName).build()); }
/** * Like {@link #setServerReceived()}, except you can log the network context of the caller, for * example an IP address from the {@code X-Forwarded-For} header. * * @param ipv4 ipv4 of the client as an int. Ex for 1.2.3.4, it would be (1 << 24) | (2 << 16) | (3 << 8) | 4 * @param port port for client-side of the socket, or 0 if unknown * @param clientService lowercase {@link Endpoint#service_name name} of the callee service or * null if unknown * * @deprecated use {@link #setServerReceived(Endpoint)} */ @Deprecated public void setServerReceived(int ipv4, int port, @Nullable String clientService) { if (clientService == null) clientService = "unknown"; setServerReceived(Endpoint.builder().ipv4(ipv4).port(port).serviceName(clientService).build()); }
builder.ipv4(ByteBuffer.wrap(addressBytes).getInt()); } else if (addressBytes.length == 16) { builder.ipv6(addressBytes);
Brave.Builder braveBuilder(Sampler sampler) { com.twitter.zipkin.gen.Endpoint localEndpoint = com.twitter.zipkin.gen.Endpoint.builder() .ipv4(127<<24|1) .ipv6(local.ipv6Bytes()) .port(local.port()) .serviceName(local.serviceName()) .build(); return new Brave.Builder(new InheritableServerClientAndLocalSpanState(localEndpoint)) .spanReporter(s -> storage.spanConsumer().accept(asList(s))) .traceSampler(sampler); }
/** * Builder. * * @param ip ipv4 host address as int. Ex for the ip 1.2.3.4, it would be (1 << 24) | (2 << 16) | (3 << 8) | 4 * @param port Port for service * @param serviceName Name of the local service being traced. Should be lowercase and not <code>null</code> or empty. */ public Builder(int ip, int port, String serviceName) { this(Endpoint.builder().serviceName(serviceName).ipv4(ip).port(port).build()); }
Brave.Builder braveBuilder(Sampler sampler) { com.twitter.zipkin.gen.Endpoint localEndpoint = com.twitter.zipkin.gen.Endpoint.builder() .ipv4(local.ipv4) .ipv6(local.ipv6) .port(local.port) .serviceName(local.serviceName) .build(); return new Brave.Builder(new InheritableServerClientAndLocalSpanState(localEndpoint)) .reporter(new Slf4jLogReporter("zipkin")) .traceSampler(sampler); } }
Brave.Builder braveBuilder(Sampler sampler) { com.twitter.zipkin.gen.Endpoint localEndpoint = com.twitter.zipkin.gen.Endpoint.builder() .ipv4(127<<24|1) .ipv6(local.ipv6Bytes()) .port(local.port()) .serviceName(local.serviceName()) .build(); return new Brave.Builder(new InheritableServerClientAndLocalSpanState(localEndpoint)) .spanReporter(s -> storage.spanConsumer().accept(asList(s))) .traceSampler(sampler); }
/** * Constructor * * @param ip Int representation of ipv4 address. * @param port port on which current process is listening. * @param serviceName Name of the local service being traced. Should be lowercase and not <code>null</code> or empty. */ public ThreadLocalServerClientAndLocalSpanState(int ip, int port, String serviceName) { this(Endpoint.builder().ipv4(ip).port(port).serviceName(serviceName).build()); }