lib/appsignal/transaction.rb in appsignal-0.12.beta.8 vs lib/appsignal/transaction.rb in appsignal-0.12.beta.9

- old
+ new

@@ -15,29 +15,28 @@ HTTP_PRAGMA HTTP_REFERER HTTP_X_FORWARDED_FOR HTTP_CLIENT_IP).freeze class << self def create(request_id, env) Appsignal.logger.debug("Creating transaction: #{request_id}") - Appsignal::Extension.start_transaction(request_id) Thread.current[:appsignal_transaction] = Appsignal::Transaction.new(request_id, env) end def current Thread.current[:appsignal_transaction] end def complete_current! if current - Appsignal::Extension.finish_transaction(current.request_id) + Appsignal::Extension.finish_transaction(current.transaction_index) Thread.current[:appsignal_transaction] = nil else Appsignal.logger.error('Trying to complete current, but no transaction present') end end end - attr_reader :request_id, :process_action_event, :action, :exception, + attr_reader :request_id, :transaction_index, :process_action_event, :action, :exception, :env, :fullpath, :time, :tags, :kind, :queue_start, :paused, :root_event_payload def initialize(request_id, env) @root_event_payload = nil @request_id = request_id @@ -45,10 +44,11 @@ @exception = nil @env = env @tags = {} @paused = false @queue_start = -1 + @transaction_index = Appsignal::Extension.start_transaction(@request_id) end def sanitized_environment @sanitized_environment ||= {} end @@ -78,28 +78,28 @@ elsif name.start_with?(Subscriber::PERFORM_JOB_PREFIX) @action = "#{@root_event_payload[:class]}##{@root_event_payload[:method]}" @kind = BACKGROUND_JOB set_background_queue_start end - Appsignal::Extension.set_transaction_basedata( - request_id, + Appsignal::Extension.set_transaction_base_data( + transaction_index, kind, action, queue_start ) end def set_metadata(key, value) return unless value - Appsignal::Extension.set_transaction_metadata(request_id, key, value) + Appsignal::Extension.set_transaction_metadata(transaction_index, key, value) end def set_error(error) return unless error Appsignal.logger.debug("Adding #{error.class.name} to transaction: #{request_id}") Appsignal::Extension.set_transaction_error( - request_id, + transaction_index, error.class.name, error.message ) { @@ -110,10 +110,10 @@ :tags => sanitized_tags }.each do |key, data| next unless data.is_a?(Array) || data.is_a?(Hash) begin Appsignal::Extension.set_transaction_error_data( - request_id, + transaction_index, key.to_s, JSON.generate(data) ) rescue JSON::GeneratorError=>e Appsignal.logger.error("JSON generate error (#{e.message}) for '#{data.inspect}'")