Sha256: f1498ff620acbdeceb599203d5e68d23d3a4da78e0a12733a5c3848a824779fc

Contents?: true

Size: 736 Bytes

Versions: 6

Compression:

Stored size: 736 Bytes

Contents

require 'action_dispatch'

module Appsignal
  class Middleware
    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

6 entries across 6 versions & 1 rubygems

Version Path
appsignal-0.4.7 lib/appsignal/middleware.rb
appsignal-0.4.6 lib/appsignal/middleware.rb
appsignal-0.4.5 lib/appsignal/middleware.rb
appsignal-0.4.4 lib/appsignal/middleware.rb
appsignal-0.4.3 lib/appsignal/middleware.rb
appsignal-0.4.0 lib/appsignal/middleware.rb