class AppsignalExtensions::Middleware::TransactionClosingBody

Acts as a wrapper for Rack response bodies. Ensures that the transaction attached to the request gets closed after the body each returns or raises

Public Class Methods

new(body, transaction) click to toggle source
# File lib/appsignal_extensions/middleware.rb, line 43
def initialize(body, transaction)
  @body, @transaction = body, transaction
end

Public Instance Methods

close() click to toggle source
# File lib/appsignal_extensions/middleware.rb, line 56
def close
  @body.close if @body.respond_to?(:close)
end
each() { |b| ... } click to toggle source
# File lib/appsignal_extensions/middleware.rb, line 47
def each
  @body.each{|b| yield(b) }
rescue Exception => e
  @transaction.set_error(e)
  raise e
ensure
  @transaction.close
end