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


48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/new_relic/agent/transaction/external_request_segment.rb', line 48

def add_request_headers request
  process_host_header request
  synthetics_header = transaction && transaction.raw_synthetics_header
  insert_synthetics_header request, synthetics_header if synthetics_header

  return unless record_metrics?

  insert_cross_app_header         request
  insert_distributed_trace_header request
rescue => e
  NewRelic::Agent.logger.error "Error in add_request_headers", e
end