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.11.18 lib/appsignal/rack/listener.rb
appsignal-0.11.17 lib/appsignal/rack/listener.rb
appsignal-0.11.16 lib/appsignal/rack/listener.rb
appsignal-0.11.15 lib/appsignal/rack/listener.rb
appsignal-0.11.14 lib/appsignal/rack/listener.rb
appsignal-0.11.14.beta.1 lib/appsignal/rack/listener.rb
appsignal-0.11.13 lib/appsignal/rack/listener.rb
appsignal-0.11.13.beta.4 lib/appsignal/rack/listener.rb
appsignal-0.11.13.beta.3 lib/appsignal/rack/listener.rb
appsignal-0.11.13.beta.2 lib/appsignal/rack/listener.rb
appsignal-0.11.13.beta.1 lib/appsignal/rack/listener.rb
appsignal-0.11.13.beta.0 lib/appsignal/rack/listener.rb
appsignal-0.11.12 lib/appsignal/rack/listener.rb
appsignal-0.11.11 lib/appsignal/rack/listener.rb
appsignal-0.11.10 lib/appsignal/rack/listener.rb
appsignal-0.11.10.beta.2 lib/appsignal/rack/listener.rb
appsignal-0.11.10.beta.1 lib/appsignal/rack/listener.rb
appsignal-0.11.9 lib/appsignal/rack/listener.rb
appsignal-0.11.8.beta.4 lib/appsignal/rack/listener.rb
appsignal-0.11.8.beta.3 lib/appsignal/rack/listener.rb