Method: NewRelic::Agent::TransactionErrorPrimitive#intrinsic_attributes_for

Defined in:
lib/new_relic/agent/transaction_error_primitive.rb

#intrinsic_attributes_for(noticed_error, payload, span_id) ⇒ Object

[View source]

51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/new_relic/agent/transaction_error_primitive.rb', line 51

def intrinsic_attributes_for(noticed_error, payload, span_id)
  attrs = {
    TYPE_KEY => SAMPLE_TYPE,
    ERROR_CLASS_KEY => noticed_error.exception_class_name,
    ERROR_MESSAGE_KEY => noticed_error.message,
    ERROR_EXPECTED_KEY => noticed_error.expected,
    TIMESTAMP_KEY => noticed_error.timestamp.to_f
  }

  attrs[SPAN_ID_KEY] = span_id if span_id
  # don't use safe navigation - leave off keys with missing values
  # instead of using nil
  attrs[PORT_KEY] = noticed_error.request_port if noticed_error.request_port
  attrs[GUID_KEY] = noticed_error.transaction_id if noticed_error.transaction_id

  if payload
    attrs[NAME_KEY] = payload[:name]
    attrs[DURATION_KEY] = payload[:duration]
    attrs[SAMPLED_KEY] = payload[:sampled] if payload.key?(:sampled)
    attrs[PRIORITY_KEY] = payload[:priority]
    append_synthetics(payload, attrs)
    append_cat(payload, attrs)
    DistributedTraceAttributes.copy_to_hash(payload, attrs)
    PayloadMetricMapping.append_mapped_metrics(payload[:metrics], attrs)
  else
    attrs[PRIORITY_KEY] = rand.round(NewRelic::PRIORITY_PRECISION)
  end

  attrs
end