class Atatus::Span::Context::Destination

@api private

Attributes

address[R]
name[R]
port[R]
resource[R]
type[R]

Public Class Methods

from_uri(uri_or_str, type: 'external', port: nil) click to toggle source
# File lib/atatus/span/context/destination.rb, line 47
def self.from_uri(uri_or_str, type: 'external', port: nil)
  uri = normalize(uri_or_str)

  new(
    name: only_scheme_and_host(uri),
    resource: "#{uri.host}:#{uri.port}",
    type: type,
    address: uri.hostname,
    port: port || uri.port
  )
end
new( name: nil, resource: nil, type: nil, address: nil, port: nil ) click to toggle source
# File lib/atatus/span/context/destination.rb, line 25
def initialize(
  name: nil,
  resource: nil,
  type: nil,
  address: nil,
  port: nil
)
  @name = name
  @resource = resource
  @type = type
  @address = address
  @port = port
end
only_scheme_and_host(uri_or_str) click to toggle source
# File lib/atatus/span/context/destination.rb, line 59
def self.only_scheme_and_host(uri_or_str)
  uri = normalize(uri_or_str)
  uri.path = ''
  uri.password = uri.query = uri.fragment = nil
  uri.to_s
end

Private Class Methods

normalize(uri_or_str) click to toggle source
# File lib/atatus/span/context/destination.rb, line 69
def normalize(uri_or_str)
  return uri_or_str.dup if uri_or_str.is_a?(URI)
  URI(uri_or_str)
end