Class: Trace::Endpoint
- Inherits:
-
Object
- Object
- Trace::Endpoint
- Defined in:
- lib/zipkin-tracer/trace.rb
Overview
This class is defined in finagle-thrift. We are adding extra methods here
Constant Summary collapse
- UNKNOWN_URL =
'unknown'.freeze
Instance Attribute Summary collapse
-
#ip_format ⇒ Object
we cannot override the initializer to add an extra parameter so use a factory.
Class Method Summary collapse
- .local_endpoint(service_port, service_name, ip_format) ⇒ Object
- .remote_endpoint(url, remote_service_name, ip_format) ⇒ Object
Instance Method Summary collapse
Instance Attribute Details
#ip_format ⇒ Object
we cannot override the initializer to add an extra parameter so use a factory
103 104 105 |
# File 'lib/zipkin-tracer/trace.rb', line 103 def ip_format @ip_format end |
Class Method Details
.local_endpoint(service_port, service_name, ip_format) ⇒ Object
105 106 107 108 |
# File 'lib/zipkin-tracer/trace.rb', line 105 def self.local_endpoint(service_port, service_name, ip_format) hostname = Socket.gethostname Endpoint.make_endpoint(hostname, service_port, service_name, ip_format) end |
.remote_endpoint(url, remote_service_name, ip_format) ⇒ Object
110 111 112 113 |
# File 'lib/zipkin-tracer/trace.rb', line 110 def self.remote_endpoint(url, remote_service_name, ip_format) service_name = remote_service_name || url.host.split('.').first || UNKNOWN_URL # default to url-derived service name Endpoint.make_endpoint(url.host, url.port, service_name, ip_format) end |
Instance Method Details
#to_h ⇒ Object
115 116 117 118 119 120 121 |
# File 'lib/zipkin-tracer/trace.rb', line 115 def to_h { ipv4: ipv4, port: port, serviceName: service_name } end |