lib/appsignal/transaction.rb in appsignal-0.8.0 vs lib/appsignal/transaction.rb in appsignal-0.8.1.beta.0
- old
+ new
@@ -20,11 +20,11 @@
def self.current
Appsignal.transactions[Thread.current[:appsignal_transaction_id]]
end
attr_reader :request_id, :events, :process_action_event, :action, :exception,
- :env, :fullpath, :time, :tags, :kind
+ :env, :fullpath, :time, :tags, :kind, :queue_start
def initialize(request_id, env)
@request_id = request_id
@events = []
@process_action_event = nil
@@ -52,17 +52,19 @@
def set_process_action_event(event)
@process_action_event = event
return unless event && event.payload
@action = "#{event.payload[:controller]}##{event.payload[:action]}"
@kind = 'http_request'
+ set_http_queue_start
end
def set_perform_job_event(event)
@process_action_event = event
return unless event && event.payload
@action = "#{event.payload[:class]}##{event.payload[:method]}"
@kind = 'background_job'
+ set_background_queue_start
end
def add_event(event)
@events << event
end
@@ -119,24 +121,21 @@
else
Appsignal.logger.debug("No process_action_event or exception: #{@request_id}")
end
end
- def queue_start
- if @kind == 'background_job'
- @process_action_event.payload[:queue_start].to_f
- else
- http_queue_start
- end
+ def set_background_queue_start
+ return unless process_action_event.payload[:queue_start]
+ @queue_start = process_action_event.payload[:queue_start].to_f
end
- def http_queue_start
+ def set_http_queue_start
return unless env
env_var = env['HTTP_X_QUEUE_START'] || env['HTTP_X_REQUEST_START']
if env_var
value = env_var.tr('^0-9', '')
unless value.empty?
- value.to_f / 1_000_000
+ @queue_start = value.to_f / 1_000_000
end
end
end
protected