Sha256: f6d876b131f9470e062bf65a070810618842e3d372695a28b24c93345f8b768a

Contents?: true

Size: 789 Bytes

Versions: 31

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.set_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

31 entries across 31 versions & 1 rubygems

Version Path
appsignal-0.12.beta.31 lib/appsignal/rack/listener.rb
appsignal-0.12.beta.30 lib/appsignal/rack/listener.rb
appsignal-0.12.beta.29 lib/appsignal/rack/listener.rb
appsignal-0.12.beta.28 lib/appsignal/rack/listener.rb
appsignal-0.12.beta.27 lib/appsignal/rack/listener.rb
appsignal-0.12.beta.26 lib/appsignal/rack/listener.rb
appsignal-0.12.beta.25 lib/appsignal/rack/listener.rb
appsignal-0.12.beta.24 lib/appsignal/rack/listener.rb
appsignal-0.12.beta.23 lib/appsignal/rack/listener.rb
appsignal-0.12.beta.22 lib/appsignal/rack/listener.rb
appsignal-0.12.beta.21 lib/appsignal/rack/listener.rb
appsignal-0.12.beta.20 lib/appsignal/rack/listener.rb
appsignal-0.12.beta.19 lib/appsignal/rack/listener.rb
appsignal-0.12.beta.18 lib/appsignal/rack/listener.rb
appsignal-0.12.beta.17 lib/appsignal/rack/listener.rb
appsignal-0.12.beta.16 lib/appsignal/rack/listener.rb
appsignal-0.12.beta.15 lib/appsignal/rack/listener.rb
appsignal-0.12.beta.14 lib/appsignal/rack/listener.rb
appsignal-0.12.beta.13 lib/appsignal/rack/listener.rb
appsignal-0.12.beta.12 lib/appsignal/rack/listener.rb