Class: ScoutApm::Extensions::TransactionCallbackPayload
- Inherits:
-
Object
- Object
- ScoutApm::Extensions::TransactionCallbackPayload
- Defined in:
- lib/scout_apm/extensions/transaction_callback_payload.rb
Overview
A TransactionCallbackPayload
is passed to each Transaction callback’s call
method. It encapsulates the data about a specific transaction.
Instance Attribute Summary collapse
-
#converter_results ⇒ Object
A Hash that stores the output of each layer converter by name.
Instance Method Summary collapse
- #app_name ⇒ Object
-
#context ⇒ Object
A flat hash of the context associated w/this transaction (ie user ip and another other data added to context).
-
#duration_ms ⇒ Object
The total duration of the transaction.
-
#error? ⇒ Boolean
Returns
true
if the transaction raised an exception. - #hostname ⇒ Object
-
#initialize(agent_context, converter_results, context, scope_layer) ⇒ TransactionCallbackPayload
constructor
A new instance of TransactionCallbackPayload.
-
#queue_time_ms ⇒ Object
The time in queue of the transaction in ms.
- #transaction_name ⇒ Object
-
#transaction_type_slug ⇒ Object
Web/Job are more language-agnostic names for controller/job.
- #transation_type ⇒ Object
Constructor Details
#initialize(agent_context, converter_results, context, scope_layer) ⇒ TransactionCallbackPayload
Returns a new instance of TransactionCallbackPayload.
9 10 11 12 13 14 |
# File 'lib/scout_apm/extensions/transaction_callback_payload.rb', line 9 def initialize(agent_context,converter_results,context,scope_layer) @agent_context = agent_context @converter_results = converter_results @context = context @scope_layer = scope_layer end |
Instance Attribute Details
#converter_results ⇒ Object
A Hash that stores the output of each layer converter by name. See the naming conventions in TrackedRequest
.
7 8 9 |
# File 'lib/scout_apm/extensions/transaction_callback_payload.rb', line 7 def converter_results @converter_results end |
Instance Method Details
#app_name ⇒ Object
44 45 46 |
# File 'lib/scout_apm/extensions/transaction_callback_payload.rb', line 44 def app_name @agent_context.config.value('name') end |
#context ⇒ Object
A flat hash of the context associated w/this transaction (ie user ip and another other data added to context).
17 18 19 |
# File 'lib/scout_apm/extensions/transaction_callback_payload.rb', line 17 def context @context.to_flat_hash end |
#duration_ms ⇒ Object
The total duration of the transaction
22 23 24 |
# File 'lib/scout_apm/extensions/transaction_callback_payload.rb', line 22 def duration_ms @scope_layer.total_call_time*1000 # ms end |
#error? ⇒ Boolean
Returns true
if the transaction raised an exception.
49 50 51 |
# File 'lib/scout_apm/extensions/transaction_callback_payload.rb', line 49 def error? converter_results[:errors] && converter_results[:errors].any? end |
#hostname ⇒ Object
40 41 42 |
# File 'lib/scout_apm/extensions/transaction_callback_payload.rb', line 40 def hostname @agent_context.environment.hostname end |
#queue_time_ms ⇒ Object
The time in queue of the transaction in ms. If not present, nil
is returned as this is unknown.
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/scout_apm/extensions/transaction_callback_payload.rb', line 27 def queue_time_ms # Controller logic if converter_results[:queue_time] && converter_results[:queue].any? converter_results[:queue_time].values.first.total_call_time*1000 # ms # Job logic elsif converter_results[:job] stat = converter_results[:job].metric_set.metrics[ScoutApm::MetricMeta.new("Latency/all", :scope => transaction_name)] stat ? stat.total_call_time*1000 : nil else nil end end |
#transaction_name ⇒ Object
57 58 59 |
# File 'lib/scout_apm/extensions/transaction_callback_payload.rb', line 57 def transaction_name @scope_layer.legacy_metric_name end |
#transaction_type_slug ⇒ Object
Web/Job are more language-agnostic names for controller/job. For example, Python Django does not have controllers.
62 63 64 65 66 67 68 69 70 71 |
# File 'lib/scout_apm/extensions/transaction_callback_payload.rb', line 62 def transaction_type_slug case transation_type when 'Controller' 'web' when 'Job' 'job' else 'transaction' end end |
#transation_type ⇒ Object
53 54 55 |
# File 'lib/scout_apm/extensions/transaction_callback_payload.rb', line 53 def transation_type @scope_layer.type end |