Module: Rollbar::Middleware::Rack::Builder

Includes:
ExceptionReporter, RequestDataExtractor
Defined in:
lib/rollbar/middleware/rack/builder.rb

Constant Summary

Constants included from RequestDataExtractor

RequestDataExtractor::ALLOWED_BODY_PARSEABLE_METHODS, RequestDataExtractor::ALLOWED_HEADERS_REGEX

Class Method Summary collapse

Instance Method Summary collapse

Methods included from RequestDataExtractor

#extract_person_data_from_controller, #extract_request_data_from_rack, #scrub_params, #scrub_url

Methods included from ExceptionReporter

#capture_uncaught?, #exception_data, #log_exception_message, #report_exception_to_rollbar

Class Method Details

.included(base) ⇒ Object



38
39
40
41
# File 'lib/rollbar/middleware/rack/builder.rb', line 38

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

Instance Method Details

#call_with_rollbar(env) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/rollbar/middleware/rack/builder.rb', line 11

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

#fetch_scope(env) ⇒ Object



24
25
26
27
28
29
30
31
32
# File 'lib/rollbar/middleware/rack/builder.rb', line 24

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

#person_data_proc(env) ⇒ Object



34
35
36
# File 'lib/rollbar/middleware/rack/builder.rb', line 34

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