class ScoutApm::Extensions::TransactionCallbackPayload

A TransactionCallbackPayload is passed to each Transaction callback's call method. It encapsulates the data about a specific transaction.

Attributes

converter_results[RW]

A Hash that stores the output of each layer converter by name. See the naming conventions in TrackedRequest.

Public Class Methods

new(agent_context,converter_results,context,scope_layer) click to toggle source
# 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

Public Instance Methods

app_name() click to toggle source
# File lib/scout_apm/extensions/transaction_callback_payload.rb, line 44
def app_name
  @agent_context.config.value('name')
end
context() click to toggle source

A flat hash of the context associated w/this transaction (ie user ip and another other data added to context).

# File lib/scout_apm/extensions/transaction_callback_payload.rb, line 17
def context
  @context.to_flat_hash
end
duration_ms() click to toggle source

The total duration of the transaction

# File lib/scout_apm/extensions/transaction_callback_payload.rb, line 22
def duration_ms
  @scope_layer.total_call_time*1000 # ms
end
error?() click to toggle source

Returns true if the transaction raised an exception.

# File lib/scout_apm/extensions/transaction_callback_payload.rb, line 49
def error?
  converter_results[:errors] && converter_results[:errors].any?
end
hostname() click to toggle source
# File lib/scout_apm/extensions/transaction_callback_payload.rb, line 40
def hostname
  @agent_context.environment.hostname
end
queue_time_ms() click to toggle source

The time in queue of the transaction in ms. If not present, nil is returned as this is unknown.

# 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_time].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() click to toggle source
# File lib/scout_apm/extensions/transaction_callback_payload.rb, line 57
def transaction_name
  @scope_layer.legacy_metric_name
end
transaction_type_slug() click to toggle source

Web/Job are more language-agnostic names for controller/job. For example, Python Django does not have controllers.

# 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() click to toggle source
# File lib/scout_apm/extensions/transaction_callback_payload.rb, line 53
def transation_type
  @scope_layer.type
end