Method: NewRelic::Agent::Transaction::ExternalRequestSegment#add_request_headers

Defined in:
lib/new_relic/agent/transaction/external_request_segment.rb

#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



63
64
65
66
67
68
69
70
71
72
73
# File 'lib/new_relic/agent/transaction/external_request_segment.rb', line 63

def add_request_headers(request)
  process_host_header(request)
  synthetics_header = transaction&.raw_synthetics_header
  insert_synthetics_header(request, synthetics_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