Method: NewRelic::Agent::Transaction::ExternalRequestSegment#get_request_metadata

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

#get_request_metadataString

Obtain an obfuscated String suitable for delivery across public networks that identifies this application and transaction to another application which is also running a New Relic agent. This String can be processed by process_request_metadata on the receiving application.

Returns:

  • (String)

    obfuscated request metadata to send


114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# File 'lib/new_relic/agent/transaction/external_request_segment.rb', line 114

def 
  NewRelic::Agent.record_api_supportability_metric(:get_request_metadata)
  return unless CrossAppTracing.cross_app_enabled?

  if transaction

    # build hash of CAT metadata
    #
    rmd = {
      NewRelicID: NewRelic::Agent.config[:cross_process_id],
      NewRelicTransaction: [
        transaction.guid,
        false,
        transaction.cat_trip_id,
        transaction.cat_path_hash
      ]
    }

    # flag cross app in the state so transaction knows to add bits to paylaod
    #
    transaction.is_cross_app_caller = true

    # add Synthetics header if we have it
    #
    rmd[:NewRelicSynthetics] = transaction.raw_synthetics_header if transaction.raw_synthetics_header

    # obfuscate the generated request metadata JSON
    #
    obfuscator.obfuscate ::JSON.dump(rmd)

  end
rescue => e
  NewRelic::Agent.logger.error "error during get_request_metadata", e
end