Class: Zipkin::Endpoint
- Inherits:
-
Object
- Object
- Zipkin::Endpoint
- Defined in:
- lib/zipkin/endpoint.rb
Defined Under Namespace
Constant Summary collapse
- LOCAL_IP =
( Socket.ip_address_list.detect(&:ipv4_private?) || Socket.ip_address_list.reverse.detect(&:ipv4?) ).ip_address
Instance Attribute Summary collapse
-
#ipv4 ⇒ Object
readonly
Returns the value of attribute ipv4.
-
#ipv6 ⇒ Object
readonly
Returns the value of attribute ipv6.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
-
#service_name ⇒ Object
readonly
Returns the value of attribute service_name.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(service_name: nil, ipv4: nil, ipv6: nil, port: nil) ⇒ Endpoint
constructor
A new instance of Endpoint.
Constructor Details
#initialize(service_name: nil, ipv4: nil, ipv6: nil, port: nil) ⇒ Endpoint
Returns a new instance of Endpoint.
56 57 58 59 60 61 |
# File 'lib/zipkin/endpoint.rb', line 56 def initialize(service_name: nil, ipv4: nil, ipv6: nil, port: nil) @service_name = service_name @ipv4 = ipv4 @ipv6 = ipv6 @port = port end |
Instance Attribute Details
#ipv4 ⇒ Object (readonly)
Returns the value of attribute ipv4.
63 64 65 |
# File 'lib/zipkin/endpoint.rb', line 63 def ipv4 @ipv4 end |
#ipv6 ⇒ Object (readonly)
Returns the value of attribute ipv6.
63 64 65 |
# File 'lib/zipkin/endpoint.rb', line 63 def ipv6 @ipv6 end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
63 64 65 |
# File 'lib/zipkin/endpoint.rb', line 63 def port @port end |
#service_name ⇒ Object (readonly)
Returns the value of attribute service_name.
63 64 65 |
# File 'lib/zipkin/endpoint.rb', line 63 def service_name @service_name end |
Class Method Details
.local_endpoint(service_name) ⇒ Object
30 31 32 |
# File 'lib/zipkin/endpoint.rb', line 30 def self.local_endpoint(service_name) new(service_name: service_name, ipv4: LOCAL_IP) end |
.remote_endpoint(span) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/zipkin/endpoint.rb', line 34 def self.remote_endpoint(span) = span. kind = ['span.kind'] || SpanKind::SERVER case kind when SpanKind::SERVER, SpanKind::CLIENT return nil if (.keys & PeerInfo.keys).empty? new( service_name: [PeerInfo::SERVICE], ipv4: [PeerInfo::IPV4], ipv6: [PeerInfo::IPV6], port: [PeerInfo::PORT] ) when SpanKind::PRODUCER, SpanKind::CONSUMER new(service_name: 'broker') else warn "Unkown span kind: #{kind}" nil end end |