class Appsignal::Rack::StreamingListener

@api private
Appsignal module that tracks exceptions in Streaming rack responses.

def call(env)

def call(env)
  if Appsignal.active?
    call_with_appsignal_monitoring(env)
  else
    @app.call(env)
  end
end

def call_with_appsignal_monitoring(env)

def call_with_appsignal_monitoring(env)
  request = ::Rack::Request.new(env)
  transaction = Appsignal::Transaction.create(
    SecureRandom.uuid,
    Appsignal::Transaction::HTTP_REQUEST,
    request
  )
  # Instrument a `process_action`, to set params/action name
  status, headers, body =
    Appsignal.instrument("process_action.rack") do
      begin
        @app.call(env)
      rescue Exception => e # rubocop:disable Lint/RescueException
        transaction.set_error(e)
        raise e
      ensure
        transaction.set_action_if_nil(env["appsignal.action"])
        transaction.set_metadata("path", request.path)
        transaction.set_metadata("method", request.request_method)
        transaction.set_http_or_background_queue_start
      end
    end
  # Wrap the result body with our StreamWrapper
  [status, headers, StreamWrapper.new(body, transaction)]
end

def initialize(app, options = {})

def initialize(app, options = {})
  Appsignal.logger.debug "Initializing Appsignal::Rack::StreamingListener"
  @app = app
  @options = options
end