Sha256: 6e1cfb740f5b962782efba6578341efca74a697f3d334b537dd1529e74313db5

Contents?: true

Size: 734 Bytes

Versions: 4

Compression:

Stored size: 734 Bytes

Contents

require 'action_dispatch'

module Appsignal
  class Listener
    def initialize(app, options = {})
      @app, @options = app, options
    end

    def call(env)
      Appsignal::Transaction.create(env['action_dispatch.request_id'], env)
      @app.call(env)
    rescue Exception => exception
      unless in_ignored_exceptions?(exception)
        Appsignal::Transaction.current.add_exception(
          Appsignal::ExceptionNotification.new(env, exception)
        )
      end
      raise exception
    ensure
      Appsignal::Transaction.current.complete!
    end

    private

    def in_ignored_exceptions?(exception)
      Array.wrap(Appsignal.config[:ignore_exceptions]).
        include?(exception.class.name)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
appsignal-0.5.5 lib/appsignal/listener.rb
appsignal-0.5.3 lib/appsignal/listener.rb
appsignal-0.5.1 lib/appsignal/listener.rb
appsignal-0.5.0 lib/appsignal/listener.rb