module NewRelic::Agent::DistributedTraceAttributes

Constants

INTRINSIC_KEYS

Intrinsic Keys

Public Instance Methods

copy_from_transaction(transaction, trace_payload, destination) click to toggle source

This method takes all distributed tracing intrinsics from the transaction and the trace_payload, and populates them into the destination

# File lib/new_relic/agent/distributed_tracing/distributed_trace_attributes.rb, line 49
def copy_from_transaction(transaction, trace_payload, destination)
  destination[GUID_KEY] = transaction.guid
  destination[SAMPLED_KEY] = transaction.sampled?
  destination[TRACE_ID_KEY] = transaction.trace_id

  if transaction.parent_span_id
    destination[PARENT_SPAN_ID_KEY] = transaction.parent_span_id
  end

  copy_parent_attributes(transaction, trace_payload, destination)
end
copy_parent_attributes(transaction, trace_payload, destination) click to toggle source
# File lib/new_relic/agent/distributed_tracing/distributed_trace_attributes.rb, line 61
def copy_parent_attributes(transaction, trace_payload, destination)
  transport_type = transaction.distributed_tracer.caller_transport_type
  destination[PARENT_TRANSPORT_TYPE_KEY] = DistributedTraceTransportType.from(transport_type)

  if trace_payload
    destination[PARENT_TYPE_KEY] = trace_payload.parent_type
    destination[PARENT_APP_KEY] = trace_payload.parent_app_id
    destination[PARENT_ACCOUNT_ID_KEY] = trace_payload.parent_account_id
    destination[PARENT_TRANSPORT_DURATION_KEY] = transaction.calculate_transport_duration(trace_payload)

    if parent_transaction_id = transaction.distributed_tracer.parent_transaction_id
      destination[PARENT_TRANSACTION_ID_KEY] = parent_transaction_id
    end
  end
end
copy_to_attributes(transaction_payload, destination) click to toggle source

This method extracts intrinsics from the transaction_payload and inserts them as intrinsics in the specified transaction_attributes

# File lib/new_relic/agent/distributed_tracing/distributed_trace_attributes.rb, line 37
def copy_to_attributes(transaction_payload, destination)
  return unless enabled?

  INTRINSIC_KEYS.each do |key|
    next unless transaction_payload.key?(key)

    destination.add_intrinsic_attribute(key, transaction_payload[key])
  end
end
copy_to_hash(transaction_payload, destination) click to toggle source

This method extracts intrinsics from the transaction_payload and inserts them into the specified destination.

# File lib/new_relic/agent/distributed_tracing/distributed_trace_attributes.rb, line 26
def copy_to_hash(transaction_payload, destination)
  return unless enabled?

  INTRINSIC_KEYS.each do |key|
    value = transaction_payload[key]
    destination[key] = value unless value.nil?
  end
end

Private Instance Methods

enabled?() click to toggle source
# File lib/new_relic/agent/distributed_tracing/distributed_trace_attributes.rb, line 79
def enabled?
  return Agent.config[:'distributed_tracing.enabled']
end