Sha256: cb871674c5e55ec9045c76ad3a5d4a43cbcec153813e97210a65a0207837e337

Contents?: true

Size: 1.17 KB

Versions: 11

Compression:

Stored size: 1.17 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 => e # rubocop:disable Lint/RescueException
              report_exception_to_rollbar(env, e)
              raise
            end
          end
        end

        def fetch_scope(env)
          {
            :request => proc { extract_request_data_from_rack(env) },
            :person => person_data_proc(env)
          }
        rescue Exception => e # rubocop:disable Lint/RescueException
          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

11 entries across 11 versions & 1 rubygems

Version Path
rollbar-3.6.0 lib/rollbar/middleware/rack/builder.rb
rollbar-3.5.2 lib/rollbar/middleware/rack/builder.rb
rollbar-3.5.1 lib/rollbar/middleware/rack/builder.rb
rollbar-3.5.0 lib/rollbar/middleware/rack/builder.rb
rollbar-3.4.2 lib/rollbar/middleware/rack/builder.rb
rollbar-3.4.1 lib/rollbar/middleware/rack/builder.rb
rollbar-3.4.0 lib/rollbar/middleware/rack/builder.rb
rollbar-3.3.3 lib/rollbar/middleware/rack/builder.rb
rollbar-3.3.2 lib/rollbar/middleware/rack/builder.rb
rollbar-3.3.1 lib/rollbar/middleware/rack/builder.rb
rollbar-3.3.0 lib/rollbar/middleware/rack/builder.rb