class ElasticAPM::Span::Context::Destination
@api private
def self.from_uri(uri_or_str, type: nil, **attrs)
def self.from_uri(uri_or_str, type: nil, **attrs) uri = normalize(uri_or_str) service = case type when 'http' then http_service(uri) else nil end new( address: uri.hostname, port: uri.port, service: service, **attrs ) end
def build_cloud(cloud = nil)
def build_cloud(cloud = nil) return Cloud.new unless cloud return cloud if cloud.is_a?(Cloud) Cloud.new(**cloud) end
def build_service(service = nil)
def build_service(service = nil) return Service.new unless service return service if service.is_a?(Service) Service.new(**service) end
def http_service(uri)
def http_service(uri) Service.new(resource: "#{uri.host}:#{uri.port}") end
def initialize(service: nil, cloud: nil, **attrs)
def initialize(service: nil, cloud: nil, **attrs) super(**attrs) self.service = build_service(service) self.cloud = build_cloud(cloud) end
def normalize(uri_or_str)
def normalize(uri_or_str) return uri_or_str.dup if uri_or_str.is_a?(URI) URI(uri_or_str) end