Class: Zipkin::Endpoint
- Inherits:
-
Object
show all
- Defined in:
- lib/zipkin/endpoint.rb
Defined Under Namespace
Modules: PeerInfo, SpanKind
Constant Summary
collapse
- LOCAL_IP =
(
Socket.ip_address_list.detect(&:ipv4_private?) ||
Socket.ip_address_list.reverse.detect(&:ipv4?)
).ip_address
Class Method Summary
collapse
Class Method Details
.local_endpoint(service_name) ⇒ Object
30
31
32
33
34
35
|
# File 'lib/zipkin/endpoint.rb', line 30
def self.local_endpoint(service_name)
{
serviceName: service_name,
ipv4: LOCAL_IP
}
end
|
.remote_endpoint(span) ⇒ Object
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
# File 'lib/zipkin/endpoint.rb', line 37
def self.remote_endpoint(span)
tags = span.tags
kind = tags[:'span.kind'] || SpanKind::SERVER
case kind
when SpanKind::SERVER, SpanKind::CLIENT
return nil if (tags.keys & PeerInfo.keys).empty?
{
serviceName: tags[PeerInfo::SERVICE],
ipv4: tags[PeerInfo::IPV4],
ipv6: tags[PeerInfo::IPV6],
port: tags[PeerInfo::PORT]
}
when SpanKind::PRODUCER, SpanKind::CONSUMER
{
serviceName: 'broker'
}
else
warn "Unkown span kind: #{kind}"
nil
end
end
|