Class: ZipkinTracer::HostnameResolver

Inherits:
Object
  • Object
show all
Defined in:
lib/zipkin-tracer/hostname_resolver.rb

Overview

Resolves hostnames in the endpoints of the spans. Resolving hostnames is a very expensive operation. We want to store them raw in the main thread and resolve them in a different thread where we do not affect execution times.

Instance Method Summary collapse

Instance Method Details

#spans_with_ips(spans, ip_format) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/zipkin-tracer/hostname_resolver.rb', line 8

def spans_with_ips(spans, ip_format)
  hosts = unique_hosts(spans)
  resolved_hosts = resolve(hosts, ip_format)

  each_endpoint(spans) do |endpoint|
    hostname = endpoint.ipv4
    next unless hostname
    next if resolved_ip_address?(hostname.to_s)

    endpoint.ipv4 = resolved_hosts[hostname]
  end
end