Sha256: 677c73cc8a253a60a6b24f979c73763cffe0d1e1bc3b26e7c584f72d00780c1f

Contents?: true

Size: 789 Bytes

Versions: 53

Compression:

Stored size: 789 Bytes

Contents

module Appsignal
  module Rack
    class Listener
      def initialize(app, options = {})
        Appsignal.logger.debug 'Initializing Appsignal::Rack::Listener'
        @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
        Appsignal.add_exception(exception)
        raise exception
      ensure
        Appsignal::Transaction.complete_current!
      end

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

Version data entries

53 entries across 53 versions & 1 rubygems

Version Path
appsignal-0.10.2 lib/appsignal/rack/listener.rb
appsignal-0.10.1 lib/appsignal/rack/listener.rb
appsignal-0.10.0 lib/appsignal/rack/listener.rb
appsignal-0.9.6 lib/appsignal/rack/listener.rb
appsignal-0.9.5 lib/appsignal/rack/listener.rb
appsignal-0.10.0.beta.0 lib/appsignal/rack/listener.rb
appsignal-0.9.4 lib/appsignal/rack/listener.rb
appsignal-0.9.3 lib/appsignal/rack/listener.rb
appsignal-0.9.2 lib/appsignal/rack/listener.rb
appsignal-0.9.1 lib/appsignal/rack/listener.rb
appsignal-0.9.0 lib/appsignal/rack/listener.rb
appsignal-0.9.0.beta.1 lib/appsignal/rack/listener.rb
appsignal-0.9.0.alpha.1 lib/appsignal/rack/listener.rb