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



127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
# File 'lib/new_relic/agent/transaction/external_request_segment.rb', line 127

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.distributed_tracer.cat_trip_id,
        transaction.distributed_tracer.cat_path_hash
      ]
    }

    # flag cross app in the state so transaction knows to add bits to payload
    #
    transaction.distributed_tracer.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