rollbar 2.8.3 → 3.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.codeclimate.yml +18 -0
- data/.github/pull_request_template.md +34 -0
- data/.github/workflows/ci.yml +67 -0
- data/.gitignore +3 -1
- data/.rubocop.yml +206 -7
- data/Appraisals +10 -10
- data/CHANGELOG.md +257 -3
- data/Gemfile +74 -13
- data/README.md +38 -833
- data/Rakefile +0 -0
- data/THANKS.md +1 -0
- data/data/rollbar.snippet.js +1 -1
- data/docs/configuration.md +64 -3
- data/docs/plugins.md +46 -0
- data/gemfiles/rails50.gemfile +56 -0
- data/gemfiles/rails51.gemfile +57 -0
- data/gemfiles/rails52.gemfile +56 -0
- data/gemfiles/rails60.gemfile +52 -0
- data/gemfiles/rails61.gemfile +52 -0
- data/gemfiles/rails70.gemfile +52 -0
- data/gemfiles/rails71.gemfile +52 -0
- data/lib/generators/rollbar/rollbar_generator.rb +24 -20
- data/lib/generators/rollbar/templates/{initializer.rb → initializer.erb} +19 -5
- data/lib/rails/rollbar_runner.rb +26 -22
- data/lib/rollbar/capistrano.rb +78 -38
- data/lib/rollbar/capistrano3.rb +62 -1
- data/lib/rollbar/capistrano_tasks.rb +166 -0
- data/lib/rollbar/configuration.rb +291 -71
- data/lib/rollbar/delay/active_job.rb +17 -0
- data/lib/rollbar/delay/delayed_job.rb +23 -0
- data/lib/rollbar/delay/girl_friday.rb +4 -9
- data/lib/rollbar/delay/resque.rb +3 -6
- data/lib/rollbar/delay/shoryuken.rb +36 -0
- data/lib/rollbar/delay/sidekiq.rb +6 -8
- data/lib/rollbar/delay/sucker_punch.rb +17 -22
- data/lib/rollbar/delay/thread.rb +74 -3
- data/lib/rollbar/deploy.rb +91 -0
- data/lib/rollbar/encoding/encoder.rb +22 -11
- data/lib/rollbar/encoding.rb +2 -7
- data/lib/rollbar/exception_reporter.rb +36 -12
- data/lib/rollbar/item/backtrace.rb +118 -0
- data/lib/rollbar/item/frame.rb +121 -0
- data/lib/rollbar/item/locals.rb +103 -0
- data/lib/rollbar/item.rb +314 -0
- data/lib/rollbar/js.rb +0 -28
- data/lib/rollbar/json.rb +7 -55
- data/lib/rollbar/language_support.rb +7 -19
- data/lib/rollbar/lazy_store.rb +8 -12
- data/lib/rollbar/logger.rb +71 -0
- data/lib/rollbar/logger_proxy.rb +18 -1
- data/lib/rollbar/middleware/js/json_value.rb +36 -0
- data/lib/rollbar/middleware/js.rb +297 -0
- data/lib/rollbar/middleware/rack/builder.rb +4 -4
- data/lib/rollbar/middleware/rack/test_session.rb +4 -4
- data/lib/rollbar/middleware/rack.rb +52 -0
- data/lib/rollbar/middleware/rails/rollbar.rb +19 -7
- data/lib/rollbar/middleware/rails/show_exceptions.rb +21 -9
- data/lib/rollbar/middleware/sinatra.rb +2 -40
- data/lib/rollbar/notifier/trace_with_bindings.rb +75 -0
- data/lib/rollbar/notifier.rb +913 -0
- data/lib/rollbar/plugin.rb +126 -0
- data/lib/rollbar/plugins/active_job.rb +54 -0
- data/lib/rollbar/plugins/basic_socket.rb +31 -0
- data/lib/rollbar/plugins/delayed_job/job_data.rb +50 -0
- data/lib/rollbar/plugins/delayed_job/plugin.rb +88 -0
- data/lib/rollbar/plugins/delayed_job.rb +12 -0
- data/lib/rollbar/plugins/error_context.rb +11 -0
- data/lib/rollbar/plugins/goalie.rb +65 -0
- data/lib/rollbar/plugins/rack.rb +18 -0
- data/lib/rollbar/plugins/rails/controller_methods.rb +56 -0
- data/lib/rollbar/plugins/rails/error_subscriber.rb +12 -0
- data/lib/rollbar/plugins/rails/railtie30.rb +18 -0
- data/lib/rollbar/plugins/rails/railtie32.rb +18 -0
- data/lib/rollbar/plugins/rails/railtie_mixin.rb +37 -0
- data/lib/rollbar/plugins/rails.rb +89 -0
- data/lib/rollbar/plugins/rake.rb +73 -0
- data/lib/rollbar/plugins/resque/failure.rb +39 -0
- data/lib/rollbar/plugins/resque.rb +11 -0
- data/lib/rollbar/plugins/sidekiq/plugin.rb +77 -0
- data/lib/rollbar/plugins/sidekiq.rb +37 -0
- data/lib/rollbar/plugins/thread.rb +14 -0
- data/lib/rollbar/plugins/validations.rb +45 -0
- data/lib/rollbar/plugins.rb +47 -0
- data/lib/rollbar/rails.rb +0 -1
- data/lib/rollbar/rake_tasks.rb +4 -66
- data/lib/rollbar/request_data_extractor.rb +157 -117
- data/lib/rollbar/rollbar_test.rb +38 -0
- data/lib/rollbar/scrubbers/params.rb +133 -0
- data/lib/rollbar/scrubbers/url.rb +90 -35
- data/lib/rollbar/scrubbers.rb +13 -0
- data/lib/rollbar/truncation/frames_strategy.rb +2 -1
- data/lib/rollbar/truncation/min_body_strategy.rb +3 -4
- data/lib/rollbar/truncation/mixin.rb +1 -1
- data/lib/rollbar/truncation/remove_any_key_strategy.rb +126 -0
- data/lib/rollbar/truncation/remove_extra_strategy.rb +37 -0
- data/lib/rollbar/truncation/remove_request_strategy.rb +21 -0
- data/lib/rollbar/truncation/strings_strategy.rb +6 -5
- data/lib/rollbar/truncation.rb +10 -4
- data/lib/rollbar/util/hash.rb +37 -6
- data/lib/rollbar/util/ip_anonymizer.rb +33 -0
- data/lib/rollbar/util/ip_obfuscator.rb +1 -1
- data/lib/rollbar/util.rb +101 -55
- data/lib/rollbar/version.rb +1 -1
- data/lib/rollbar.rb +91 -879
- data/lib/tasks/benchmark.rake +104 -0
- data/lib/tasks/tasks.rake +3 -3
- data/rollbar.gemspec +21 -32
- data/spec/support/rollbar_api.rb +67 -0
- metadata +78 -439
- data/.travis.yml +0 -155
- data/gemfiles/rails30.gemfile +0 -20
- data/gemfiles/rails31.gemfile +0 -16
- data/gemfiles/rails32.gemfile +0 -17
- data/gemfiles/rails40.gemfile +0 -17
- data/gemfiles/rails41.gemfile +0 -15
- data/gemfiles/rails42.gemfile +0 -15
- data/lib/rollbar/active_job.rb +0 -11
- data/lib/rollbar/active_record_extension.rb +0 -14
- data/lib/rollbar/core_ext/basic_socket.rb +0 -7
- data/lib/rollbar/core_ext/thread.rb +0 -9
- data/lib/rollbar/delayed_job.rb +0 -78
- data/lib/rollbar/encoding/legacy_encoder.rb +0 -20
- data/lib/rollbar/goalie.rb +0 -33
- data/lib/rollbar/js/frameworks/rails.rb +0 -29
- data/lib/rollbar/js/frameworks.rb +0 -6
- data/lib/rollbar/js/middleware.rb +0 -129
- data/lib/rollbar/js/version.rb +0 -5
- data/lib/rollbar/json/default.rb +0 -11
- data/lib/rollbar/json/oj.rb +0 -15
- data/lib/rollbar/rack.rb +0 -9
- data/lib/rollbar/rails/controller_methods.rb +0 -40
- data/lib/rollbar/railtie.rb +0 -46
- data/lib/rollbar/rake.rb +0 -38
- data/lib/rollbar/sidekiq.rb +0 -40
- data/lib/rollbar/tasks/rollbar.cap +0 -45
- data/spec/cacert.pem +0 -3988
- data/spec/controllers/home_controller_spec.rb +0 -455
- data/spec/delay/sidekiq_spec.rb +0 -61
- data/spec/delay/sucker_punch_spec.rb +0 -25
- data/spec/delayed/backend/test.rb +0 -139
- data/spec/delayed/serialization/test.rb +0 -0
- data/spec/dummyapp/.gitignore +0 -73
- data/spec/dummyapp/Rakefile +0 -7
- data/spec/dummyapp/app/assets/javascripts/application.js +0 -3
- data/spec/dummyapp/app/assets/stylesheets/application.css.scss +0 -37
- data/spec/dummyapp/app/controllers/application_controller.rb +0 -3
- data/spec/dummyapp/app/controllers/home_controller.rb +0 -60
- data/spec/dummyapp/app/controllers/users_controller.rb +0 -17
- data/spec/dummyapp/app/helpers/.gitkeep +0 -0
- data/spec/dummyapp/app/mailers/.gitkeep +0 -0
- data/spec/dummyapp/app/models/.gitkeep +0 -0
- data/spec/dummyapp/app/models/user.rb +0 -7
- data/spec/dummyapp/app/views/devise/registrations/edit.html.erb +0 -27
- data/spec/dummyapp/app/views/devise/registrations/new.html.erb +0 -20
- data/spec/dummyapp/app/views/devise/shared/_links.html.erb +0 -25
- data/spec/dummyapp/app/views/home/cause_exception.html.erb +0 -1
- data/spec/dummyapp/app/views/home/index.html.erb +0 -4
- data/spec/dummyapp/app/views/home/report_exception.html.erb +0 -1
- data/spec/dummyapp/app/views/js/test.html.erb +0 -1
- data/spec/dummyapp/app/views/layouts/_messages.html.erb +0 -5
- data/spec/dummyapp/app/views/layouts/_navigation.html.erb +0 -21
- data/spec/dummyapp/app/views/layouts/application.html.erb +0 -25
- data/spec/dummyapp/app/views/layouts/simple.html.erb +0 -18
- data/spec/dummyapp/app/views/users/index.html.erb +0 -8
- data/spec/dummyapp/app/views/users/show.html.erb +0 -3
- data/spec/dummyapp/config/application.rb +0 -59
- data/spec/dummyapp/config/boot.rb +0 -10
- data/spec/dummyapp/config/database.yml +0 -25
- data/spec/dummyapp/config/environment.rb +0 -5
- data/spec/dummyapp/config/environments/development.rb +0 -37
- data/spec/dummyapp/config/environments/production.rb +0 -67
- data/spec/dummyapp/config/environments/test.rb +0 -37
- data/spec/dummyapp/config/initializers/backtrace_silencers.rb +0 -7
- data/spec/dummyapp/config/initializers/inflections.rb +0 -15
- data/spec/dummyapp/config/initializers/mime_types.rb +0 -5
- data/spec/dummyapp/config/initializers/rollbar.rb +0 -23
- data/spec/dummyapp/config/initializers/secret_token.rb +0 -7
- data/spec/dummyapp/config/initializers/session_store.rb +0 -8
- data/spec/dummyapp/config/initializers/wrap_parameters.rb +0 -16
- data/spec/dummyapp/config/locales/devise.en.yml +0 -58
- data/spec/dummyapp/config/locales/en.yml +0 -5
- data/spec/dummyapp/config/routes.rb +0 -17
- data/spec/dummyapp/config.ru +0 -4
- data/spec/dummyapp/db/migrate/20121121184652_devise_create_users.rb +0 -46
- data/spec/dummyapp/db/migrate/20121121184654_add_name_to_users.rb +0 -5
- data/spec/dummyapp/db/schema.rb +0 -35
- data/spec/dummyapp/db/seeds.rb +0 -12
- data/spec/dummyapp/lib/assets/.gitkeep +0 -0
- data/spec/dummyapp/public/404.html +0 -26
- data/spec/dummyapp/public/422.html +0 -26
- data/spec/dummyapp/public/500.html +0 -25
- data/spec/dummyapp/public/favicon.ico +0 -0
- data/spec/dummyapp/script/rails +0 -6
- data/spec/fixtures/file1 +0 -1
- data/spec/fixtures/file2 +0 -1
- data/spec/fixtures/payloads/message.json +0 -25
- data/spec/fixtures/payloads/sample.trace.json +0 -275
- data/spec/fixtures/payloads/sample.trace_chain.json +0 -530
- data/spec/generators/rollbar/rollbar_generator_spec.rb +0 -24
- data/spec/requests/home_spec.rb +0 -49
- data/spec/rollbar/active_job_spec.rb +0 -33
- data/spec/rollbar/configuration_spec.rb +0 -24
- data/spec/rollbar/delay/girl_friday_spec.rb +0 -41
- data/spec/rollbar/delay/resque_spec.rb +0 -37
- data/spec/rollbar/delay/thread_spec.rb +0 -27
- data/spec/rollbar/delayed_job/job_data.rb +0 -35
- data/spec/rollbar/delayed_job_spec.rb +0 -90
- data/spec/rollbar/encoding/encoder_spec.rb +0 -63
- data/spec/rollbar/js/frameworks/rails_spec.rb +0 -19
- data/spec/rollbar/js/middleware_spec.rb +0 -162
- data/spec/rollbar/json/oj_spec.rb +0 -18
- data/spec/rollbar/json_spec.rb +0 -110
- data/spec/rollbar/lazy_store_spec.rb +0 -99
- data/spec/rollbar/logger_proxy_spec.rb +0 -34
- data/spec/rollbar/middleware/rack/builder_spec.rb +0 -151
- data/spec/rollbar/middleware/sinatra_spec.rb +0 -197
- data/spec/rollbar/rake_spec.rb +0 -34
- data/spec/rollbar/request_data_extractor_spec.rb +0 -82
- data/spec/rollbar/scrubbers/url_spec.rb +0 -111
- data/spec/rollbar/sidekiq_spec.rb +0 -90
- data/spec/rollbar/truncation/frames_strategy_spec.rb +0 -70
- data/spec/rollbar/truncation/min_body_strategy_spec.rb +0 -57
- data/spec/rollbar/truncation/strings_strategy_spec.rb +0 -89
- data/spec/rollbar/truncation_spec.rb +0 -27
- data/spec/rollbar/util/hash_spec.rb +0 -22
- data/spec/rollbar/util_spec.rb +0 -19
- data/spec/rollbar_bc_spec.rb +0 -380
- data/spec/rollbar_spec.rb +0 -2067
- data/spec/spec_helper.rb +0 -49
- data/spec/support/cause_exception.rb +0 -1
- data/spec/support/encoding_helpers.rb +0 -8
- data/spec/support/encodings/iso_8859_9 +0 -1
- data/spec/support/fixture_helpers.rb +0 -10
- data/spec/support/get_ip_raising.rb +0 -7
- data/spec/support/helpers.rb +0 -5
- data/spec/support/notifier_helpers.rb +0 -36
- data/spec/support/shared_contexts.rb +0 -12
@@ -0,0 +1,126 @@
|
|
1
|
+
module Rollbar
|
2
|
+
# Represents a plugin in the gem. Every plugin can have multiple dependencies
|
3
|
+
# and multiple execution blocks.
|
4
|
+
# On Rollbar initialization, all plugins will be saved in memory and those that
|
5
|
+
# satisfy the dependencies will be loaded
|
6
|
+
class Plugin
|
7
|
+
attr_reader :name, :dependencies, :callables, :revert_callables
|
8
|
+
attr_accessor :on_demand, :loaded
|
9
|
+
|
10
|
+
private :loaded=
|
11
|
+
|
12
|
+
def initialize(name)
|
13
|
+
@name = name
|
14
|
+
@dependencies = []
|
15
|
+
@callables = []
|
16
|
+
@revert_callables = []
|
17
|
+
@loaded = false
|
18
|
+
@on_demand = false
|
19
|
+
end
|
20
|
+
|
21
|
+
def load_on_demand
|
22
|
+
@on_demand = true
|
23
|
+
end
|
24
|
+
|
25
|
+
def configuration
|
26
|
+
Rollbar.configuration
|
27
|
+
end
|
28
|
+
|
29
|
+
def load_scoped!(transparent = false)
|
30
|
+
if transparent
|
31
|
+
load! if load?
|
32
|
+
|
33
|
+
result = yield
|
34
|
+
|
35
|
+
unload! if loaded
|
36
|
+
else
|
37
|
+
return unless load?
|
38
|
+
|
39
|
+
load!
|
40
|
+
|
41
|
+
result = yield
|
42
|
+
|
43
|
+
unload!
|
44
|
+
end
|
45
|
+
|
46
|
+
result
|
47
|
+
end
|
48
|
+
|
49
|
+
def load!
|
50
|
+
return unless load?
|
51
|
+
|
52
|
+
begin
|
53
|
+
callables.each(&:call)
|
54
|
+
rescue StandardError => e
|
55
|
+
log_loading_error(e)
|
56
|
+
ensure
|
57
|
+
self.loaded = true
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def unload!
|
62
|
+
return unless loaded
|
63
|
+
|
64
|
+
begin
|
65
|
+
revert_callables.each(&:call)
|
66
|
+
rescue StandardError => e
|
67
|
+
log_unloading_error(e)
|
68
|
+
ensure
|
69
|
+
self.loaded = false
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def execute(&block)
|
74
|
+
callables << block
|
75
|
+
end
|
76
|
+
|
77
|
+
def execute!
|
78
|
+
yield if load?
|
79
|
+
end
|
80
|
+
|
81
|
+
def revert(&block)
|
82
|
+
revert_callables << block
|
83
|
+
end
|
84
|
+
|
85
|
+
private
|
86
|
+
|
87
|
+
def dependency(&block)
|
88
|
+
dependencies << block
|
89
|
+
end
|
90
|
+
|
91
|
+
def require_dependency(file)
|
92
|
+
dependency do
|
93
|
+
begin
|
94
|
+
require file
|
95
|
+
true
|
96
|
+
rescue LoadError
|
97
|
+
false
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
def load?
|
103
|
+
!loaded && dependencies_satisfy?
|
104
|
+
rescue StandardError => e
|
105
|
+
log_loading_error(e)
|
106
|
+
|
107
|
+
false
|
108
|
+
end
|
109
|
+
|
110
|
+
def dependencies_satisfy?
|
111
|
+
dependencies.all?(&:call)
|
112
|
+
end
|
113
|
+
|
114
|
+
def log_loading_error(error)
|
115
|
+
Rollbar.log_error(
|
116
|
+
"Error trying to load plugin '#{name}': #{error.class}, #{error.message}"
|
117
|
+
)
|
118
|
+
end
|
119
|
+
|
120
|
+
def log_unloading_error(error)
|
121
|
+
Rollbar.log_error(
|
122
|
+
"Error trying to unload plugin '#{name}': #{error.class}, #{error.message}"
|
123
|
+
)
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
module Rollbar
|
2
|
+
# Report any uncaught errors in a job to Rollbar and reraise
|
3
|
+
module ActiveJob
|
4
|
+
def self.included(base)
|
5
|
+
base.send :rescue_from, Exception do |exception|
|
6
|
+
job_data = {
|
7
|
+
:job => self.class.name,
|
8
|
+
:use_exception_level_filters => true
|
9
|
+
}
|
10
|
+
|
11
|
+
# When included in ActionMailer, the handler is called twice.
|
12
|
+
# This detects the execution that has the expected state.
|
13
|
+
if defined?(ActionMailer::Base) && self.class.ancestors.include?(ActionMailer::Base)
|
14
|
+
job_data[:action] = action_name
|
15
|
+
job_data[:params] = @params
|
16
|
+
|
17
|
+
Rollbar.error(exception, job_data)
|
18
|
+
|
19
|
+
# This detects other supported integrations.
|
20
|
+
elsif defined?(arguments)
|
21
|
+
job_data[:arguments] = \
|
22
|
+
if self.class.respond_to?(:log_arguments?) && !self.class.log_arguments?
|
23
|
+
arguments.map(&Rollbar::Scrubbers.method(:scrub_value))
|
24
|
+
else
|
25
|
+
arguments
|
26
|
+
end
|
27
|
+
job_data[:job_id] = job_id if defined?(job_id)
|
28
|
+
|
29
|
+
Rollbar.error(exception, job_data)
|
30
|
+
end
|
31
|
+
|
32
|
+
raise exception
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
Rollbar.plugins.define('active_job') do
|
39
|
+
dependency { !configuration.disable_monkey_patch }
|
40
|
+
dependency { !configuration.disable_action_mailer_monkey_patch }
|
41
|
+
|
42
|
+
execute do
|
43
|
+
if defined?(ActiveSupport) && ActiveSupport.respond_to?(:on_load)
|
44
|
+
ActiveSupport.on_load(:action_mailer) do
|
45
|
+
if defined?(ActionMailer::MailDeliveryJob) # Rails >= 6.0
|
46
|
+
ActionMailer::Base.send(:include, Rollbar::ActiveJob)
|
47
|
+
elsif defined?(ActionMailer::DeliveryJob) # Rails < 6.0
|
48
|
+
ActionMailer::DeliveryJob.send(:include,
|
49
|
+
Rollbar::ActiveJob)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
Rollbar.plugins.define('basic_socket') do
|
2
|
+
load_on_demand
|
3
|
+
|
4
|
+
dependency { !configuration.disable_core_monkey_patch }
|
5
|
+
|
6
|
+
# Needed to avoid active_support (< 4.1.0) bug serializing JSONs
|
7
|
+
dependency do
|
8
|
+
defined?(ActiveSupport::VERSION::STRING) &&
|
9
|
+
Gem::Version.new(ActiveSupport::VERSION::STRING) < Gem::Version.new('4.1.0')
|
10
|
+
end
|
11
|
+
|
12
|
+
execute do
|
13
|
+
class BasicSocket # :nodoc:
|
14
|
+
def new_as_json(_options = nil)
|
15
|
+
{
|
16
|
+
:value => inspect
|
17
|
+
}
|
18
|
+
end
|
19
|
+
# alias_method is recommended over alias when aliasing at runtime.
|
20
|
+
# https://github.com/rubocop-hq/ruby-style-guide#alias-method
|
21
|
+
alias_method :original_as_json, :as_json # rubocop:disable Style/Alias
|
22
|
+
alias_method :as_json, :new_as_json # rubocop:disable Style/Alias
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
revert do
|
27
|
+
class BasicSocket # :nodoc:
|
28
|
+
alias_method :as_json, :original_as_json # rubocop:disable Style/Alias
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module Rollbar
|
2
|
+
module Delayed
|
3
|
+
class JobData
|
4
|
+
attr_reader :job
|
5
|
+
|
6
|
+
def initialize(job)
|
7
|
+
@job = job
|
8
|
+
end
|
9
|
+
|
10
|
+
def to_hash
|
11
|
+
job_data = extract_job_data
|
12
|
+
|
13
|
+
handler_parent = job_data['job'] || job_data
|
14
|
+
handler_parent['handler'] = handler_data
|
15
|
+
|
16
|
+
job_data
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def extract_job_data
|
22
|
+
if job.respond_to?(:as_json)
|
23
|
+
job.as_json
|
24
|
+
else
|
25
|
+
Hash[job.to_hash.map { |k, v| [k.to_s, v] }]
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def handler_data
|
30
|
+
payload_object = job.payload_object
|
31
|
+
|
32
|
+
return payload_object unless payload_object.respond_to?(:object)
|
33
|
+
|
34
|
+
object_data(payload_object.object)
|
35
|
+
rescue StandardError
|
36
|
+
{}
|
37
|
+
end
|
38
|
+
|
39
|
+
def object_data(object)
|
40
|
+
{
|
41
|
+
:method_name => job.payload_object.method_name,
|
42
|
+
:args => job.payload_object.args,
|
43
|
+
:object => object.is_a?(Class) ? object.name : object.to_s
|
44
|
+
}
|
45
|
+
rescue StandardError
|
46
|
+
{}
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
require 'delayed_job'
|
2
|
+
require 'rollbar/plugins/delayed_job/job_data'
|
3
|
+
|
4
|
+
module Rollbar
|
5
|
+
module Delayed
|
6
|
+
class << self
|
7
|
+
attr_accessor :wrapped
|
8
|
+
end
|
9
|
+
|
10
|
+
class RollbarPlugin < ::Delayed::Plugin
|
11
|
+
callbacks do |lifecycle|
|
12
|
+
lifecycle.around(:invoke_job, &Delayed.invoke_job_callback)
|
13
|
+
lifecycle.after(:failure) do |_, job, _, _|
|
14
|
+
data = Rollbar::Delayed.build_job_data(job)
|
15
|
+
|
16
|
+
# DelayedJob < 4.1 doesn't provide job#error
|
17
|
+
if job.class.method_defined? :error
|
18
|
+
if job.error
|
19
|
+
::Rollbar.scope(:request => data)
|
20
|
+
.error(job.error, :use_exception_level_filters => true)
|
21
|
+
end
|
22
|
+
elsif job.last_error
|
23
|
+
::Rollbar.scope(:request => data).error(
|
24
|
+
"Job has failed and won't be retried anymore: #{job.last_error}",
|
25
|
+
:use_exception_level_filters => true
|
26
|
+
)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
self.wrapped = false
|
33
|
+
|
34
|
+
def self.wrap_worker
|
35
|
+
return if wrapped
|
36
|
+
|
37
|
+
::Delayed::Worker.plugins << RollbarPlugin
|
38
|
+
|
39
|
+
self.wrapped = true
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.wrap_worker!
|
43
|
+
self.wrapped = false
|
44
|
+
|
45
|
+
wrap_worker
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.invoke_job_callback
|
49
|
+
proc do |job, *args, &block|
|
50
|
+
begin
|
51
|
+
if Rollbar.configuration.dj_use_scoped_block
|
52
|
+
data = Rollbar::Delayed.build_job_data(job)
|
53
|
+
Rollbar.scoped(:request => data) { block.call(job, *args) }
|
54
|
+
else
|
55
|
+
block.call(job, *args)
|
56
|
+
end
|
57
|
+
rescue StandardError => e
|
58
|
+
report(e, job)
|
59
|
+
|
60
|
+
raise e
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def self.report(e, job)
|
66
|
+
return if skip_report?(job)
|
67
|
+
|
68
|
+
data = build_job_data(job)
|
69
|
+
|
70
|
+
::Rollbar.scope(:request => data)
|
71
|
+
.error(e, :use_exception_level_filters => true)
|
72
|
+
end
|
73
|
+
|
74
|
+
def self.skip_report?(job)
|
75
|
+
handler = ::Rollbar.configuration.async_skip_report_handler
|
76
|
+
|
77
|
+
return handler.call(job) if handler.respond_to?(:call)
|
78
|
+
|
79
|
+
job.attempts < ::Rollbar.configuration.dj_threshold
|
80
|
+
end
|
81
|
+
|
82
|
+
def self.build_job_data(job)
|
83
|
+
return nil unless ::Rollbar.configuration.report_dj_data
|
84
|
+
|
85
|
+
JobData.new(job).to_hash
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
Rollbar.plugins.define('delayed_job') do
|
2
|
+
dependency { !configuration.disable_monkey_patch }
|
3
|
+
dependency do
|
4
|
+
defined?(Delayed) && defined?(Delayed::Worker) && configuration.delayed_job_enabled
|
5
|
+
end
|
6
|
+
|
7
|
+
execute do
|
8
|
+
require 'rollbar/plugins/delayed_job/plugin'
|
9
|
+
|
10
|
+
Rollbar::Delayed.wrap_worker
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
Rollbar.plugins.define('goalie') do
|
2
|
+
dependency { !configuration.disable_monkey_patch }
|
3
|
+
dependency { defined?(Goalie) }
|
4
|
+
|
5
|
+
execute do
|
6
|
+
module Rollbar
|
7
|
+
module Goalie
|
8
|
+
def render_exception_with_rollbar(env, exception)
|
9
|
+
exception_data = nil
|
10
|
+
|
11
|
+
begin
|
12
|
+
controller = env['action_controller.instance']
|
13
|
+
request_data = begin
|
14
|
+
controller.rollbar_request_data
|
15
|
+
rescue StandardError
|
16
|
+
nil
|
17
|
+
end
|
18
|
+
person_data = begin
|
19
|
+
controller.rollbar_person_data
|
20
|
+
rescue StandardError
|
21
|
+
nil
|
22
|
+
end
|
23
|
+
exception_data = Rollbar.scope(
|
24
|
+
:request => request_data,
|
25
|
+
:person => person_data
|
26
|
+
).error(exception, :use_exception_level_filters => true)
|
27
|
+
rescue StandardError => e
|
28
|
+
message = "[Rollbar] Exception while reporting exception to Rollbar: #{e}"
|
29
|
+
Rollbar.log_warning(message)
|
30
|
+
end
|
31
|
+
|
32
|
+
# if an exception was reported, save uuid in the env
|
33
|
+
# so it can be displayed to the user on the error page
|
34
|
+
case exception_data
|
35
|
+
when Hash
|
36
|
+
env['rollbar.exception_uuid'] = exception_data[:uuid]
|
37
|
+
Rollbar.log_info(
|
38
|
+
"[Rollbar] Exception uuid saved in env: #{exception_data[:uuid]}"
|
39
|
+
)
|
40
|
+
when 'disabled'
|
41
|
+
Rollbar.log_info(
|
42
|
+
'[Rollbar] Exception not reported because Rollbar is disabled'
|
43
|
+
)
|
44
|
+
when 'ignored'
|
45
|
+
Rollbar.log_info(
|
46
|
+
'[Rollbar] Exception not reported because it was ignored'
|
47
|
+
)
|
48
|
+
end
|
49
|
+
|
50
|
+
# now continue as normal
|
51
|
+
render_exception_without_rollbar(env, exception)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
execute do
|
58
|
+
Goalie::CustomErrorPages.class_eval do
|
59
|
+
include Rollbar::Goalie
|
60
|
+
|
61
|
+
alias_method :render_exception_without_rollbar, :render_exception
|
62
|
+
alias_method :render_exception, :render_exception_with_rollbar
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
Rollbar.plugins.define('rack') do
|
2
|
+
dependency { !configuration.disable_monkey_patch }
|
3
|
+
dependency { !configuration.disable_rack_monkey_patch }
|
4
|
+
|
5
|
+
execute do
|
6
|
+
if defined?(Rack::Builder)
|
7
|
+
require 'rollbar/middleware/rack'
|
8
|
+
require 'rollbar/middleware/rack/builder'
|
9
|
+
Rack::Builder.send(:include, Rollbar::Middleware::Rack::Builder)
|
10
|
+
end
|
11
|
+
|
12
|
+
if defined?(Rack::Test::Session)
|
13
|
+
require 'rollbar/middleware/rack'
|
14
|
+
require 'rollbar/middleware/rack/test_session'
|
15
|
+
Rack::Test::Session.send(:include, Rollbar::Middleware::Rack::TestSession)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'rollbar/request_data_extractor'
|
2
|
+
require 'rollbar/util'
|
3
|
+
|
4
|
+
module Rollbar
|
5
|
+
module Rails
|
6
|
+
module ControllerMethods
|
7
|
+
include RequestDataExtractor
|
8
|
+
|
9
|
+
def rollbar_person_data
|
10
|
+
user = nil
|
11
|
+
unless Rollbar::Util.method_in_stack_twice(:rollbar_person_data, __FILE__)
|
12
|
+
user = send(Rollbar.configuration.person_method)
|
13
|
+
end
|
14
|
+
|
15
|
+
# include id, username, email if non-empty
|
16
|
+
if user
|
17
|
+
{
|
18
|
+
:id => (begin
|
19
|
+
user.send(Rollbar.configuration.person_id_method)
|
20
|
+
rescue StandardError
|
21
|
+
nil
|
22
|
+
end),
|
23
|
+
:username => (begin
|
24
|
+
user.send(Rollbar.configuration.person_username_method)
|
25
|
+
rescue StandardError
|
26
|
+
nil
|
27
|
+
end),
|
28
|
+
:email => (begin
|
29
|
+
user.send(Rollbar.configuration.person_email_method)
|
30
|
+
rescue StandardError
|
31
|
+
nil
|
32
|
+
end)
|
33
|
+
}
|
34
|
+
else
|
35
|
+
{}
|
36
|
+
end
|
37
|
+
rescue NameError
|
38
|
+
{}
|
39
|
+
end
|
40
|
+
|
41
|
+
def rollbar_request_data
|
42
|
+
extract_request_data_from_rack(request.env)
|
43
|
+
end
|
44
|
+
|
45
|
+
# for backwards compatabilty with the old ratchetio-gem
|
46
|
+
def ratchetio_person_data
|
47
|
+
rollbar_person_data
|
48
|
+
end
|
49
|
+
|
50
|
+
# for backwards compatabilty with the old ratchetio-gem
|
51
|
+
def ratchetio_request_data
|
52
|
+
rollbar_request_data
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Rollbar
|
2
|
+
class ErrorSubscriber
|
3
|
+
def report(error, handled:, severity:, context:, source: nil)
|
4
|
+
# The default `nil` for capture_uncaught means `true`. so check for false.
|
5
|
+
return unless handled || Rollbar.configuration.capture_uncaught != false
|
6
|
+
|
7
|
+
extra = context.is_a?(Hash) ? context.deep_dup : {}
|
8
|
+
extra[:custom_data_method_context] = source
|
9
|
+
Rollbar.log(severity, error, extra)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'rails/railtie'
|
2
|
+
require 'rollbar/plugins/rails/railtie_mixin'
|
3
|
+
|
4
|
+
module Rollbar
|
5
|
+
class Railtie < ::Rails::Railtie
|
6
|
+
include Rollbar::RailtieMixin
|
7
|
+
|
8
|
+
initializer 'rollbar.middleware.rails' do |app|
|
9
|
+
require 'rollbar/middleware/rails/rollbar'
|
10
|
+
require 'rollbar/middleware/rails/show_exceptions'
|
11
|
+
|
12
|
+
app.config.middleware.insert_after ActionDispatch::ShowExceptions,
|
13
|
+
Rollbar::Middleware::Rails::RollbarMiddleware
|
14
|
+
ActionDispatch::ShowExceptions.send(:include,
|
15
|
+
Rollbar::Middleware::Rails::ShowExceptions)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'rails/railtie'
|
2
|
+
require 'rollbar/plugins/rails/railtie_mixin'
|
3
|
+
|
4
|
+
module Rollbar
|
5
|
+
class Railtie < ::Rails::Railtie
|
6
|
+
include Rollbar::RailtieMixin
|
7
|
+
|
8
|
+
initializer 'rollbar.middleware.rails' do |app|
|
9
|
+
require 'rollbar/middleware/rails/rollbar'
|
10
|
+
require 'rollbar/middleware/rails/show_exceptions'
|
11
|
+
|
12
|
+
app.config.middleware.insert_after ActionDispatch::DebugExceptions,
|
13
|
+
Rollbar::Middleware::Rails::RollbarMiddleware
|
14
|
+
ActionDispatch::DebugExceptions.send(:include,
|
15
|
+
Rollbar::Middleware::Rails::ShowExceptions)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Rollbar
|
2
|
+
module RailtieMixin
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
included do
|
6
|
+
rake_tasks do
|
7
|
+
require 'rollbar/rake_tasks'
|
8
|
+
end
|
9
|
+
|
10
|
+
initializer 'rollbar.configuration' do
|
11
|
+
config.after_initialize do
|
12
|
+
Rollbar.preconfigure do |config|
|
13
|
+
config.default_logger = proc { ::Rails.logger }
|
14
|
+
config.environment ||= ::Rails.env
|
15
|
+
config.root ||= ::Rails.root
|
16
|
+
config.framework = "Rails: #{::Rails::VERSION::STRING}"
|
17
|
+
config.filepath ||= begin
|
18
|
+
if ::Rails.application.class.respond_to?(:module_parent_name)
|
19
|
+
"#{::Rails.application.class.module_parent_name}.rollbar"
|
20
|
+
else
|
21
|
+
"#{::Rails.application.class.parent_name}.rollbar"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
initializer 'rollbar.controller_methods' do
|
29
|
+
ActiveSupport.on_load(:action_controller) do
|
30
|
+
# lazily load action_controller methods
|
31
|
+
require 'rollbar/plugins/rails/controller_methods'
|
32
|
+
include Rollbar::Rails::ControllerMethods
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
Rollbar.plugins.define('rails32-errors') do
|
2
|
+
dependency { defined?(Rails::VERSION) && Rails::VERSION::MAJOR >= 3 }
|
3
|
+
dependency { Gem::Version.new(Rails::VERSION::STRING) >= Gem::Version.new('3.2') }
|
4
|
+
|
5
|
+
execute! do
|
6
|
+
require 'rollbar/plugins/rails/railtie32'
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
Rollbar.plugins.define('rails30-errors') do
|
11
|
+
dependency { defined?(Rails::VERSION) && Rails::VERSION::MAJOR >= 3 }
|
12
|
+
dependency { Gem::Version.new(Rails::VERSION::STRING) < Gem::Version.new('3.2') }
|
13
|
+
|
14
|
+
execute! do
|
15
|
+
require 'rollbar/plugins/rails/railtie30'
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
Rollbar.plugins.define('rails-rollbar.js') do
|
20
|
+
dependency { defined?(Rails::VERSION) && Rails::VERSION::MAJOR >= 3 }
|
21
|
+
|
22
|
+
execute! do
|
23
|
+
module Rollbar
|
24
|
+
module Js
|
25
|
+
module Frameworks
|
26
|
+
# Adds Rollbar::Middleware::Js to the Rails middleware stack
|
27
|
+
# We need to delay the final insert to the last moment since
|
28
|
+
# this feature may be disable.
|
29
|
+
# But we need to prepare the middleware insert now because
|
30
|
+
# we need to use our Rails railtie initializer in case the
|
31
|
+
# customer is using SecureHeaders > 3.0
|
32
|
+
class Rails
|
33
|
+
def load(plugin)
|
34
|
+
plugin_execute = plugin_execute_proc_body(plugin)
|
35
|
+
|
36
|
+
return after_secure_headers(&plugin_execute) if secure_headers_middleware?
|
37
|
+
|
38
|
+
plugin_execute.call
|
39
|
+
end
|
40
|
+
|
41
|
+
def after_secure_headers(&block)
|
42
|
+
Rollbar::Railtie.initializer('rollbar.js.frameworks.rails',
|
43
|
+
:after => 'secure_headers.middleware', &block)
|
44
|
+
end
|
45
|
+
|
46
|
+
def plugin_execute_proc_body(plugin)
|
47
|
+
proc do
|
48
|
+
plugin.execute do
|
49
|
+
if Rollbar.configuration.js_enabled
|
50
|
+
require 'rollbar/middleware/js'
|
51
|
+
|
52
|
+
config = {
|
53
|
+
:options => Rollbar.configuration.js_options,
|
54
|
+
:enabled => Rollbar.configuration.js_enabled
|
55
|
+
}
|
56
|
+
::Rails.configuration.middleware.use(::Rollbar::Middleware::Js,
|
57
|
+
config)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def secure_headers_middleware?
|
64
|
+
begin
|
65
|
+
require 'secure_headers'
|
66
|
+
rescue LoadError
|
67
|
+
# Skip loading
|
68
|
+
end
|
69
|
+
|
70
|
+
defined?(::SecureHeaders::Middleware)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
execute! do
|
79
|
+
Rollbar::Js::Frameworks::Rails.new.load(self)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
Rollbar.plugins.define('rails-error-subscriber') do
|
84
|
+
dependency { defined?(Rails::VERSION) && Rails::VERSION::MAJOR >= 7 }
|
85
|
+
|
86
|
+
execute! do
|
87
|
+
require 'rollbar/plugins/rails/error_subscriber'
|
88
|
+
end
|
89
|
+
end
|