Class: NewRelic::Agent::DistributedTracePayload
- Inherits:
-
Object
- Object
- NewRelic::Agent::DistributedTracePayload
show all
- Extended by:
- Coerce
- Defined in:
- lib/new_relic/agent/distributed_tracing/distributed_trace_payload.rb
Overview
This class contains properties related to distributed traces. To obtain an instance, call DistributedTracing#create_distributed_trace_payload
Constant Summary
collapse
- VERSION =
[0, 1].freeze
- PARENT_TYPE =
'App'
- VERSION_KEY =
Key names for serialization
'v'
- DATA_KEY =
'd'
- PARENT_TYPE_KEY =
'ty'
- PARENT_ACCOUNT_ID_KEY =
'ac'
- PARENT_APP_KEY =
'ap'
- TRUSTED_ACCOUNT_KEY =
'tk'
- ID_KEY =
'id'
- TX_KEY =
'tx'
- TRACE_ID_KEY =
'tr'
- SAMPLED_KEY =
'sa'
- TIMESTAMP_KEY =
'ti'
- PRIORITY_KEY =
'pr'
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Coerce
boolean_int!, float, float!, int, int!, int_or_nil, log_failure, scalar, string, value_or_nil
Instance Attribute Details
#id ⇒ Object
106
107
108
|
# File 'lib/new_relic/agent/distributed_tracing/distributed_trace_payload.rb', line 106
def id
@id
end
|
#parent_account_id ⇒ Object
106
107
108
|
# File 'lib/new_relic/agent/distributed_tracing/distributed_trace_payload.rb', line 106
def parent_account_id
@parent_account_id
end
|
#parent_app_id ⇒ Object
106
107
108
|
# File 'lib/new_relic/agent/distributed_tracing/distributed_trace_payload.rb', line 106
def parent_app_id
@parent_app_id
end
|
#parent_type ⇒ Object
106
107
108
|
# File 'lib/new_relic/agent/distributed_tracing/distributed_trace_payload.rb', line 106
def parent_type
@parent_type
end
|
#priority ⇒ Object
106
107
108
|
# File 'lib/new_relic/agent/distributed_tracing/distributed_trace_payload.rb', line 106
def priority
@priority
end
|
#sampled ⇒ Object
Also known as:
sampled?
106
107
108
|
# File 'lib/new_relic/agent/distributed_tracing/distributed_trace_payload.rb', line 106
def sampled
@sampled
end
|
#timestamp ⇒ Object
106
107
108
|
# File 'lib/new_relic/agent/distributed_tracing/distributed_trace_payload.rb', line 106
def timestamp
@timestamp
end
|
#trace_id ⇒ Object
106
107
108
|
# File 'lib/new_relic/agent/distributed_tracing/distributed_trace_payload.rb', line 106
def trace_id
@trace_id
end
|
#transaction_id ⇒ Object
106
107
108
|
# File 'lib/new_relic/agent/distributed_tracing/distributed_trace_payload.rb', line 106
def transaction_id
@transaction_id
end
|
#trusted_account_key ⇒ Object
106
107
108
|
# File 'lib/new_relic/agent/distributed_tracing/distributed_trace_payload.rb', line 106
def trusted_account_key
@trusted_account_key
end
|
#version ⇒ Object
106
107
108
|
# File 'lib/new_relic/agent/distributed_tracing/distributed_trace_payload.rb', line 106
def version
@version
end
|
Class Method Details
.for_transaction(transaction) ⇒ Object
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/new_relic/agent/distributed_tracing/distributed_trace_payload.rb', line 37
def for_transaction(transaction)
return nil unless Agent.instance.connected?
payload = new
payload.version = VERSION
payload.parent_type = PARENT_TYPE
payload.parent_account_id = Agent.config[:account_id]
payload.parent_app_id = Agent.config[:primary_application_id]
assign_trusted_account_key(payload, payload.parent_account_id)
payload.id = current_segment_id(transaction)
payload.transaction_id = transaction.guid
payload.timestamp = Process.clock_gettime(Process::CLOCK_REALTIME, :millisecond)
payload.trace_id = transaction.trace_id
payload.sampled = transaction.sampled?
payload.priority = transaction.priority
payload
end
|
.from_http_safe(http_safe_payload) ⇒ Object
80
81
82
83
|
# File 'lib/new_relic/agent/distributed_tracing/distributed_trace_payload.rb', line 80
def from_http_safe(http_safe_payload)
decoded_payload = NewRelic::Base64.strict_decode64(http_safe_payload)
from_json(decoded_payload)
end
|
.from_json(serialized_payload) ⇒ Object
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
# File 'lib/new_relic/agent/distributed_tracing/distributed_trace_payload.rb', line 58
def from_json(serialized_payload)
raw_payload = JSON.parse(serialized_payload)
return raw_payload if raw_payload.nil?
payload_data = raw_payload[DATA_KEY]
payload = new
payload.version = raw_payload[VERSION_KEY]
payload.parent_type = payload_data[PARENT_TYPE_KEY]
payload.parent_account_id = payload_data[PARENT_ACCOUNT_ID_KEY]
payload.parent_app_id = payload_data[PARENT_APP_KEY]
payload.trusted_account_key = payload_data[TRUSTED_ACCOUNT_KEY]
payload.timestamp = payload_data[TIMESTAMP_KEY]
payload.id = payload_data[ID_KEY]
payload.transaction_id = payload_data[TX_KEY]
payload.trace_id = payload_data[TRACE_ID_KEY]
payload.sampled = payload_data[SAMPLED_KEY]
payload.priority = payload_data[PRIORITY_KEY]
payload
end
|
.major_version_matches?(payload) ⇒ Boolean
85
86
87
|
# File 'lib/new_relic/agent/distributed_tracing/distributed_trace_payload.rb', line 85
def major_version_matches?(payload)
payload.version[0] == VERSION[0]
end
|
Instance Method Details
#http_safe ⇒ String
Encode this payload as a string suitable for passing via an HTTP header.
154
155
156
|
# File 'lib/new_relic/agent/distributed_tracing/distributed_trace_payload.rb', line 154
def http_safe
NewRelic::Base64.strict_encode64(text)
end
|
#text ⇒ String
Represent this payload as a raw JSON string.