Module: NewRelic::Agent::CrossAppTracing
- Included in:
- Transaction::DistributedTracer
- Defined in:
- lib/new_relic/agent/distributed_tracing/cross_app_tracing.rb
Constant Summary collapse
- NR_APPDATA_HEADER =
The cross app response header for “outgoing” calls
'X-NewRelic-App-Data'
- NR_ID_HEADER =
The cross app id header for “outgoing” calls
'X-NewRelic-ID'
- NR_TXN_HEADER =
The cross app transaction header for “outgoing” calls
'X-NewRelic-Transaction'
- NR_MESSAGE_BROKER_ID_HEADER =
'NewRelicID'
- NR_MESSAGE_BROKER_TXN_HEADER =
'NewRelicTransaction'
- NR_MESSAGE_BROKER_SYNTHETICS_HEADER =
'NewRelicSynthetics'
Instance Attribute Summary collapse
-
#cat_path_hashes ⇒ Object
Returns the value of attribute cat_path_hashes.
-
#cross_app_payload ⇒ Object
Returns the value of attribute cross_app_payload.
-
#is_cross_app_caller ⇒ Object
Returns the value of attribute is_cross_app_caller.
Instance Method Summary collapse
- #add_message_cat_headers(headers) ⇒ Object
- #assign_cross_app_intrinsics ⇒ Object
- #cat_path_hash ⇒ Object
- #cat_trip_id ⇒ Object
- #cross_app_monitor ⇒ Object
- #insert_cross_app_header(headers) ⇒ Object
- #is_cross_app? ⇒ Boolean
- #is_cross_app_callee? ⇒ Boolean
- #is_cross_app_caller? ⇒ Boolean
- #record_cross_app_metrics ⇒ Object
Instance Attribute Details
#cat_path_hashes ⇒ Object
Returns the value of attribute cat_path_hashes.
23 24 25 |
# File 'lib/new_relic/agent/distributed_tracing/cross_app_tracing.rb', line 23 def cat_path_hashes @cat_path_hashes end |
#cross_app_payload ⇒ Object
Returns the value of attribute cross_app_payload.
23 24 25 |
# File 'lib/new_relic/agent/distributed_tracing/cross_app_tracing.rb', line 23 def cross_app_payload @cross_app_payload end |
#is_cross_app_caller ⇒ Object
Returns the value of attribute is_cross_app_caller.
23 24 25 |
# File 'lib/new_relic/agent/distributed_tracing/cross_app_tracing.rb', line 23 def is_cross_app_caller @is_cross_app_caller end |
Instance Method Details
#add_message_cat_headers(headers) ⇒ Object
64 65 66 67 68 69 70 71 72 73 |
# File 'lib/new_relic/agent/distributed_tracing/cross_app_tracing.rb', line 64 def (headers) return unless CrossAppTracing.cross_app_enabled? @is_cross_app_caller = true (headers, transaction.guid, cat_trip_id, cat_path_hash, transaction.raw_synthetics_header) end |
#assign_cross_app_intrinsics ⇒ Object
85 86 87 88 |
# File 'lib/new_relic/agent/distributed_tracing/cross_app_tracing.rb', line 85 def assign_cross_app_intrinsics transaction.attributes.add_intrinsic_attribute(:trip_id, cat_trip_id) transaction.attributes.add_intrinsic_attribute(:path_hash, cat_path_hash) end |
#cat_path_hash ⇒ Object
45 46 47 48 49 50 51 |
# File 'lib/new_relic/agent/distributed_tracing/cross_app_tracing.rb', line 45 def cat_path_hash referring_path_hash = cat_referring_path_hash || '0' seed = referring_path_hash.to_i(16) result = cross_app_monitor.path_hash(transaction.best_name, seed) record_cat_path_hash(result) result end |
#cat_trip_id ⇒ Object
37 38 39 |
# File 'lib/new_relic/agent/distributed_tracing/cross_app_tracing.rb', line 37 def cat_trip_id cross_app_payload&.referring_trip_id || transaction.guid end |
#cross_app_monitor ⇒ Object
41 42 43 |
# File 'lib/new_relic/agent/distributed_tracing/cross_app_tracing.rb', line 41 def cross_app_monitor NewRelic::Agent.instance.monitors.cross_app_monitor end |
#insert_cross_app_header(headers) ⇒ Object
53 54 55 56 57 58 59 60 61 62 |
# File 'lib/new_relic/agent/distributed_tracing/cross_app_tracing.rb', line 53 def insert_cross_app_header(headers) return unless CrossAppTracing.cross_app_enabled? @is_cross_app_caller = true txn_guid = transaction.guid trip_id = cat_trip_id path_hash = cat_path_hash insert_request_headers(headers, txn_guid, trip_id, path_hash) end |
#is_cross_app? ⇒ Boolean
33 34 35 |
# File 'lib/new_relic/agent/distributed_tracing/cross_app_tracing.rb', line 33 def is_cross_app? is_cross_app_caller? || is_cross_app_callee? end |
#is_cross_app_callee? ⇒ Boolean
29 30 31 |
# File 'lib/new_relic/agent/distributed_tracing/cross_app_tracing.rb', line 29 def is_cross_app_callee? !cross_app_payload.nil? end |
#is_cross_app_caller? ⇒ Boolean
25 26 27 |
# File 'lib/new_relic/agent/distributed_tracing/cross_app_tracing.rb', line 25 def is_cross_app_caller? @is_cross_app_caller ||= false end |
#record_cross_app_metrics ⇒ Object
75 76 77 78 79 80 81 82 83 |
# File 'lib/new_relic/agent/distributed_tracing/cross_app_tracing.rb', line 75 def record_cross_app_metrics if (id = cross_app_payload&.id) app_time_in_seconds = [ Process.clock_gettime(Process::CLOCK_REALTIME) - transaction.start_time, 0.0 ].max NewRelic::Agent.record_metric("ClientApplication/#{id}/all", app_time_in_seconds) end end |