Class: NewRelic::Agent::Transaction::ExternalRequestSegment

Inherits:
Segment
  • Object
show all
Defined in:
lib/new_relic/agent/transaction/external_request_segment.rb

Overview

This class represents an external segment in a transaction trace.

Instance Method Summary collapse

Instance Method Details

#add_request_headers(request) ⇒ Object

This method adds New Relic request headers to a given request made to an external API and checks to see if a host header is used for the request. If a host header is used, it updates the segment name to match the host header.

object (must belong to a subclass of NewRelic::Agent::HTTPClients::AbstractRequest)

Parameters:

  • request (NewRelic::Agent::HTTPClients::AbstractRequest)

    the request



54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/new_relic/agent/transaction/external_request_segment.rb', line 54

def add_request_headers(request)
  process_host_header(request)
  synthetics_header = transaction&.raw_synthetics_header
  synthetics_info_header = transaction&.raw_synthetics_info_header
  insert_synthetics_header(request, synthetics_header, synthetics_info_header) if synthetics_header

  return unless record_metrics?

  transaction.distributed_tracer.insert_headers(request)
rescue => e
  NewRelic::Agent.logger.error('Error in add_request_headers', e)
end