Module: NewRelic::Agent::OpenTelemetry::Segments::HttpExternal

Included in:
Trace::Tracer
Defined in:
lib/new_relic/agent/opentelemetry/segments/http_external.rb

Instance Method Summary collapse

Instance Method Details

#create_uri(attributes) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/new_relic/agent/opentelemetry/segments/http_external.rb', line 10

def create_uri(attributes)
  scheme = attributes['url.scheme'] || attributes['http.scheme']
  host = attributes['server.address'] || attributes['net.peer.name']
  port = attributes['server.port'] || attributes['net.peer.port']
  path = attributes['url.path'] || attributes['http.target'] || NewRelic::SLASH

  # if we don't have all the pieces we need to build a full URI,
  # fall back to the full URL representations;
  # though these don't usually have a port
  if [scheme, host, port, path].any?(&:nil?)
    attributes['url.full'] || attributes['http.url']
  else
    "#{scheme}://#{host}:#{port}#{path}"
  end
end