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.15 lib/appsignal/rack/listener.rb
appsignal-0.8.14 lib/appsignal/rack/listener.rb
appsignal-0.8.13 lib/appsignal/rack/listener.rb
appsignal-0.8.12 lib/appsignal/rack/listener.rb
appsignal-0.8.11 lib/appsignal/rack/listener.rb
appsignal-0.8.10 lib/appsignal/rack/listener.rb
appsignal-0.8.8 lib/appsignal/rack/listener.rb
appsignal-0.8.7 lib/appsignal/rack/listener.rb
appsignal-0.8.7.alpha.1 lib/appsignal/rack/listener.rb
appsignal-0.8.6 lib/appsignal/rack/listener.rb
appsignal-0.8.6.beta.1 lib/appsignal/rack/listener.rb
appsignal-0.8.6.beta.0 lib/appsignal/rack/listener.rb
appsignal-0.8.5 lib/appsignal/rack/listener.rb
appsignal-0.8.4 lib/appsignal/rack/listener.rb
appsignal-0.8.4.beta.1 lib/appsignal/rack/listener.rb
appsignal-0.8.4.beta.0 lib/appsignal/rack/listener.rb
appsignal-0.8.3 lib/appsignal/rack/listener.rb
appsignal-0.8.3.beta.1 lib/appsignal/rack/listener.rb
appsignal-0.8.3.beta.0 lib/appsignal/rack/listener.rb
appsignal-0.8.2 lib/appsignal/rack/listener.rb