class ElasticAPM::Span::Context::Destination
@api private
def self.from_uri(uri_or_str, type: 'external', port: nil)
def self.from_uri(uri_or_str, type: 'external', port: nil) uri = normalize(uri_or_str) service = Service.new( name: only_scheme_and_host(uri), resource: "#{uri.host}:#{uri.port}", type: type ) new( address: uri.hostname, port: port || uri.port, service: service ) end
def self.only_scheme_and_host(uri_or_str)
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
def build_cloud(cloud = nil)
def build_cloud(cloud = nil) return unless cloud return cloud if cloud.is_a?(Cloud) Cloud.new(**cloud) end
def build_service(service = nil)
def build_service(service = nil) return unless service return service if service.is_a?(Service) Service.new(**service) rescue Service::MissingValues nil # If we are missing any service value, return nothing end
def initialize(
def initialize( address: nil, port: nil, service: nil, cloud: nil ) @address = address @port = port @service = build_service(service) @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