Sha256: de4100699db2a332e4dc341f30b14d41d52d9969d344f2540b4d3c7e37ee276d

Contents?: true

Size: 1.11 KB

Versions: 43

Compression:

Stored size: 1.11 KB

Contents

require 'rollbar/exception_reporter'
require 'rollbar/request_data_extractor'

module Rollbar
  module Middleware
    class Rack
      module Builder
        include ExceptionReporter
        include RequestDataExtractor

        def call_with_rollbar(env)
          Rollbar.reset_notifier!

          Rollbar.scoped(fetch_scope(env)) do
            begin
              call_without_rollbar(env)
            rescue ::Exception => exception
              report_exception_to_rollbar(env, exception)
              raise
            end
          end
        end

        def fetch_scope(env)
          {
            :request => proc { extract_request_data_from_rack(env) },
            :person => person_data_proc(env)
          }
        rescue Exception => e
          report_exception_to_rollbar(env, e)
          raise
        end

        def person_data_proc(env)
          proc { extract_person_data_from_controller(env) }
        end

        def self.included(base)
          base.send(:alias_method, :call_without_rollbar, :call)
          base.send(:alias_method, :call, :call_with_rollbar)
        end
      end
    end
  end
end

Version data entries

43 entries across 43 versions & 1 rubygems

Version Path
rollbar-3.2.0 lib/rollbar/middleware/rack/builder.rb
rollbar-3.1.2 lib/rollbar/middleware/rack/builder.rb
rollbar-3.1.1 lib/rollbar/middleware/rack/builder.rb
rollbar-3.1.0 lib/rollbar/middleware/rack/builder.rb
rollbar-3.0.1 lib/rollbar/middleware/rack/builder.rb
rollbar-3.0.0 lib/rollbar/middleware/rack/builder.rb
rollbar-2.27.1 lib/rollbar/middleware/rack/builder.rb
rollbar-2.27.0 lib/rollbar/middleware/rack/builder.rb
rollbar-2.26.1 lib/rollbar/middleware/rack/builder.rb
rollbar-2.26.0 lib/rollbar/middleware/rack/builder.rb
rollbar-2.25.1 lib/rollbar/middleware/rack/builder.rb
rollbar-2.25.0 lib/rollbar/middleware/rack/builder.rb
rollbar-2.24.0 lib/rollbar/middleware/rack/builder.rb
rollbar-2.23.2 lib/rollbar/middleware/rack/builder.rb
rollbar-2.23.1 lib/rollbar/middleware/rack/builder.rb
rollbar-2.23.0 lib/rollbar/middleware/rack/builder.rb
rollbar-2.22.1 lib/rollbar/middleware/rack/builder.rb
rollbar-2.22.0 lib/rollbar/middleware/rack/builder.rb
rollbar-2.21.0 lib/rollbar/middleware/rack/builder.rb
rollbar-2.20.2 lib/rollbar/middleware/rack/builder.rb