Class: Trace::Endpoint
- Inherits:
-
Struct
- Object
- Struct
- Trace::Endpoint
- Defined in:
- lib/zipkin-tracer/trace.rb
Constant Summary collapse
- UNKNOWN_URL =
'unknown'.freeze
Instance Attribute Summary collapse
-
#ipv4 ⇒ Object
Returns the value of attribute ipv4.
-
#port ⇒ Object
Returns the value of attribute port.
-
#service_name ⇒ Object
Returns the value of attribute service_name.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#ipv4 ⇒ Object
Returns the value of attribute ipv4
271 272 273 |
# File 'lib/zipkin-tracer/trace.rb', line 271 def ipv4 @ipv4 end |
#port ⇒ Object
Returns the value of attribute port
271 272 273 |
# File 'lib/zipkin-tracer/trace.rb', line 271 def port @port end |
#service_name ⇒ Object
Returns the value of attribute service_name
271 272 273 |
# File 'lib/zipkin-tracer/trace.rb', line 271 def service_name @service_name end |
Class Method Details
.local_endpoint(service_name) ⇒ Object
274 275 276 277 |
# File 'lib/zipkin-tracer/trace.rb', line 274 def self.local_endpoint(service_name) hostname = Socket.gethostname Endpoint.new(hostname, nil, service_name) end |
.remote_endpoint(url, remote_service_name) ⇒ Object
279 280 281 282 |
# File 'lib/zipkin-tracer/trace.rb', line 279 def self.remote_endpoint(url, remote_service_name) service_name = remote_service_name || url&.host&.split('.')&.first || UNKNOWN_URL # default to url-derived service name Endpoint.new(url&.host, url&.port, service_name) end |
Instance Method Details
#to_h ⇒ Object
284 285 286 287 288 289 290 291 |
# File 'lib/zipkin-tracer/trace.rb', line 284 def to_h hsh = { ipv4: ipv4, serviceName: service_name } hsh[:port] = port if port hsh end |