Method: NewRelic::Agent::DistributedTracing#insert_distributed_trace_headers
- Defined in:
- lib/new_relic/agent/distributed_tracing.rb
#insert_distributed_trace_headers(headers = {}) ⇒ Transaction
Adds the Distributed Trace headers so that the downstream service can participate in a distributed trace. This method should be called every time an outbound call is made since the header payload contains a timestamp.
Distributed Tracing must be enabled to use this method.
insert_distributed_trace_headers
always inserts W3C trace context headers and inserts New Relic distributed tracing header by default. New Relic headers may be suppressed by setting exclude_new_relic_header
to true
in your configuration file.
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/new_relic/agent/distributed_tracing.rb', line 44 def insert_distributed_trace_headers(headers = {}) record_api_supportability_metric(:insert_distributed_trace_headers) unless Agent.config[:'distributed_tracing.enabled'] NewRelic::Agent.logger.debug('Not configured to insert distributed trace headers') return nil end return unless valid_api_argument_class?(headers, 'headers', Hash) return unless transaction = Transaction.tl_current transaction.distributed_tracer.insert_headers(headers) transaction rescue => e NewRelic::Agent.logger.error('error during insert_distributed_trace_headers', e) nil end |