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


68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/new_relic/agent/transaction/external_request_segment.rb', line 68

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