Method: NewRelic::Agent::Transaction::ExternalRequestSegment#read_response_headers

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

#read_response_headers(response) ⇒ Object

This method extracts app data from an external response if present. If a valid cross-app ID is found, the name of the segment is updated to reflect the cross-process ID and transaction name.

Parameters:

  • response (Hash)

    a hash of response headers



84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/new_relic/agent/transaction/external_request_segment.rb', line 84

def read_response_headers(response)
  return unless record_metrics? && CrossAppTracing.cross_app_enabled?
  return unless CrossAppTracing.response_has_crossapp_header?(response)

  unless data = CrossAppTracing.extract_appdata(response)
    NewRelic::Agent.logger.debug("Couldn't extract_appdata from external segment response")
    return
  end

  if CrossAppTracing.valid_cross_app_id?(data[0])
    @app_data = data
    update_segment_name
  else
    NewRelic::Agent.logger.debug('External segment response has invalid cross_app_id')
  end
rescue => e
  NewRelic::Agent.logger.error('Error in read_response_headers', e)
end