Sha256: e8ae14ef94bfaa27757f40e82e74ef0d3907a6ef5cca07f4ad9bc6a5156fea4a

Contents?: true

Size: 810 Bytes

Versions: 37

Compression:

Stored size: 810 Bytes

Contents

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

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

      def call_with_appsignal_monitoring(env)
        Appsignal::Transaction.create(request_id(env), env)
        @app.call(env)
      rescue Exception => exception
        unless Appsignal.is_ignored_exception?(exception)
          Appsignal::Transaction.current.add_exception(exception)
        end
        raise exception
      ensure
        Appsignal::Transaction.current.complete!
      end

      def request_id(env)
        env['action_dispatch.request_id'] || SecureRandom.uuid
      end
    end
  end
end

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
appsignal-0.8.1 lib/appsignal/rack/listener.rb
appsignal-0.8.1.beta.4 lib/appsignal/rack/listener.rb
appsignal-0.8.1.beta.3 lib/appsignal/rack/listener.rb
appsignal-0.8.1.beta.2 lib/appsignal/rack/listener.rb
appsignal-0.8.1.beta.1 lib/appsignal/rack/listener.rb
appsignal-0.8.1.beta.0 lib/appsignal/rack/listener.rb
appsignal-0.8.0 lib/appsignal/rack/listener.rb
appsignal-0.8.0.beta.1 lib/appsignal/rack/listener.rb
appsignal-0.8.0.beta.0 lib/appsignal/rack/listener.rb
appsignal-0.8.0.alpha.0 lib/appsignal/rack/listener.rb
appsignal-0.7.1 lib/appsignal/rack/listener.rb
appsignal-0.7.1.beta.1 lib/appsignal/rack/listener.rb
appsignal-0.7.0.beta.1 lib/appsignal/rack/listener.rb
appsignal-0.7.0.alpha.4 lib/appsignal/rack/listener.rb
appsignal-0.7.0.alpha.3 lib/appsignal/rack/listener.rb
appsignal-0.7.0.alpha.2 lib/appsignal/rack/listener.rb
appsignal-0.7.0.alpha.1 lib/appsignal/rack/listener.rb