rollbar 2.20.1 → 2.21.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 +4 -4
- data/.rubocop.yml +5 -0
- data/.travis.yml +42 -16
- data/Gemfile +19 -13
- data/data/rollbar.snippet.js +1 -1
- data/gemfiles/rails30.gemfile +1 -10
- data/gemfiles/rails31.gemfile +1 -9
- data/gemfiles/rails32.gemfile +1 -9
- data/gemfiles/rails40.gemfile +1 -9
- data/gemfiles/rails41.gemfile +1 -9
- data/gemfiles/rails42.gemfile +1 -11
- data/gemfiles/rails50.gemfile +1 -11
- data/gemfiles/rails51.gemfile +1 -11
- data/gemfiles/rails52.gemfile +1 -11
- data/gemfiles/rails60.gemfile +67 -0
- data/lib/rollbar/json.rb +2 -51
- data/lib/rollbar/language_support.rb +3 -19
- data/lib/rollbar/notifier.rb +1 -3
- data/lib/rollbar/plugins/basic_socket.rb +1 -1
- data/lib/rollbar/rake_tasks.rb +3 -147
- data/lib/rollbar/request_data_extractor.rb +1 -2
- data/lib/rollbar/rollbar_test.rb +147 -0
- data/lib/rollbar/scrubbers/url.rb +0 -1
- data/lib/rollbar/truncation.rb +3 -1
- data/lib/rollbar/truncation/remove_any_key_strategy.rb +123 -0
- data/lib/rollbar/util.rb +2 -2
- data/lib/rollbar/util/hash.rb +15 -0
- data/lib/rollbar/version.rb +1 -1
- data/rollbar.gemspec +0 -2
- metadata +6 -20
- data/gemfiles/ruby_1_8_and_1_9_2.gemfile +0 -51
- data/lib/rollbar/json/default.rb +0 -11
- data/lib/rollbar/json/oj.rb +0 -16
data/lib/rollbar/json.rb
CHANGED
@@ -1,13 +1,5 @@
|
|
1
|
-
require 'multi_json'
|
2
|
-
require 'rollbar/json/oj'
|
3
|
-
require 'rollbar/json/default'
|
4
1
|
require 'rollbar/language_support'
|
5
2
|
|
6
|
-
begin
|
7
|
-
require 'oj'
|
8
|
-
rescue LoadError
|
9
|
-
end
|
10
|
-
|
11
3
|
module Rollbar
|
12
4
|
module JSON # :nodoc:
|
13
5
|
extend self
|
@@ -15,54 +7,13 @@ module Rollbar
|
|
15
7
|
attr_writer :options_module
|
16
8
|
|
17
9
|
def dump(object)
|
18
|
-
# `basic_socket` plugin addresses the following issue: https://github.com/rollbar/rollbar-gem/issues/845
|
19
10
|
Rollbar.plugins.get('basic_socket').load_scoped!(true) do
|
20
|
-
|
11
|
+
::JSON.generate(object)
|
21
12
|
end
|
22
13
|
end
|
23
14
|
|
24
15
|
def load(string)
|
25
|
-
|
26
|
-
end
|
27
|
-
|
28
|
-
def with_adapter(&block)
|
29
|
-
MultiJson.with_adapter(detect_multi_json_adapter, &block)
|
30
|
-
end
|
31
|
-
|
32
|
-
def detect_multi_json_adapter
|
33
|
-
options = {}
|
34
|
-
options[:adapter] = :oj if defined?(::Oj)
|
35
|
-
|
36
|
-
MultiJson.current_adapter(options)
|
37
|
-
end
|
38
|
-
|
39
|
-
def adapter_options
|
40
|
-
options_module.options
|
41
|
-
end
|
42
|
-
|
43
|
-
def options_module
|
44
|
-
@options_module ||= find_options_module
|
45
|
-
end
|
46
|
-
|
47
|
-
def find_options_module
|
48
|
-
module_name = multi_json_adapter_module_name
|
49
|
-
|
50
|
-
if LanguageSupport.const_defined?(Rollbar::JSON, module_name, false)
|
51
|
-
LanguageSupport.const_get(Rollbar::JSON, module_name, false)
|
52
|
-
else
|
53
|
-
Default
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
# MultiJson adapters have this name structure:
|
58
|
-
# "MultiJson::Adapters::{AdapterModule}"
|
59
|
-
#
|
60
|
-
# Ex: MultiJson::Adapters::Oj
|
61
|
-
# Ex: MultiJson::Adapters::JsonGem
|
62
|
-
#
|
63
|
-
# In this method we just get the last module name.
|
64
|
-
def multi_json_adapter_module_name
|
65
|
-
detect_multi_json_adapter.name[/^MultiJson::Adapters::(.*)$/, 1]
|
16
|
+
::JSON.parse(string)
|
66
17
|
end
|
67
18
|
end
|
68
19
|
end
|
@@ -3,27 +3,11 @@ module Rollbar
|
|
3
3
|
module_function
|
4
4
|
|
5
5
|
def const_defined?(mod, target, inherit = true)
|
6
|
-
|
7
|
-
mod.const_defined?(target)
|
8
|
-
else
|
9
|
-
mod.const_defined?(target, inherit)
|
10
|
-
end
|
6
|
+
mod.const_defined?(target, inherit)
|
11
7
|
end
|
12
8
|
|
13
9
|
def const_get(mod, target, inherit = true)
|
14
|
-
|
15
|
-
mod.const_get(target)
|
16
|
-
else
|
17
|
-
mod.const_get(target, inherit)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
def can_scrub_url?
|
22
|
-
!version?('1.8')
|
23
|
-
end
|
24
|
-
|
25
|
-
def ruby_18?
|
26
|
-
version?('1.8')
|
10
|
+
mod.const_get(target, inherit)
|
27
11
|
end
|
28
12
|
|
29
13
|
def ruby_19?
|
@@ -37,7 +21,7 @@ module Rollbar
|
|
37
21
|
end
|
38
22
|
|
39
23
|
def timeout_exceptions
|
40
|
-
return [] if
|
24
|
+
return [] if ruby_19?
|
41
25
|
|
42
26
|
[Net::ReadTimeout, Net::OpenTimeout]
|
43
27
|
end
|
data/lib/rollbar/notifier.rb
CHANGED
@@ -557,8 +557,6 @@ module Rollbar
|
|
557
557
|
|
558
558
|
if uri.scheme == 'https'
|
559
559
|
http.use_ssl = true
|
560
|
-
# This is needed to have 1.8.7 passing tests
|
561
|
-
http.ca_file = ENV['ROLLBAR_SSL_CERT_FILE'] if ENV.key?('ROLLBAR_SSL_CERT_FILE')
|
562
560
|
http.verify_mode = ssl_verify_mode
|
563
561
|
end
|
564
562
|
|
@@ -639,7 +637,7 @@ module Rollbar
|
|
639
637
|
end
|
640
638
|
|
641
639
|
def skip_retries?
|
642
|
-
Rollbar::LanguageSupport.
|
640
|
+
Rollbar::LanguageSupport.ruby_19?
|
643
641
|
end
|
644
642
|
|
645
643
|
def handle_response(response)
|
@@ -6,7 +6,7 @@ Rollbar.plugins.define('basic_socket') do
|
|
6
6
|
# Needed to avoid active_support (< 4.1.0) bug serializing JSONs
|
7
7
|
dependency do
|
8
8
|
defined?(ActiveSupport::VERSION::STRING) &&
|
9
|
-
Gem::Version.new(ActiveSupport::VERSION::STRING) < Gem::Version.new('
|
9
|
+
Gem::Version.new(ActiveSupport::VERSION::STRING) < Gem::Version.new('4.1.0')
|
10
10
|
end
|
11
11
|
|
12
12
|
execute do
|
data/lib/rollbar/rake_tasks.rb
CHANGED
@@ -1,154 +1,10 @@
|
|
1
|
-
require 'rollbar'
|
2
|
-
begin
|
3
|
-
require 'rack/mock'
|
4
|
-
rescue LoadError
|
5
|
-
puts 'Cannot load rack/mock'
|
6
|
-
end
|
7
|
-
require 'logger'
|
8
1
|
|
9
2
|
namespace :rollbar do
|
10
3
|
desc 'Verify your gem installation by sending a test exception to Rollbar'
|
11
4
|
task :test => [:environment] do
|
12
|
-
|
13
|
-
|
14
|
-
end
|
15
|
-
|
16
|
-
# Module to inject into the Rails controllers or rack apps
|
17
|
-
module RollbarTest # :nodoc:
|
18
|
-
def test_rollbar
|
19
|
-
puts 'Raising RollbarTestingException to simulate app failure.'
|
20
|
-
|
21
|
-
raise RollbarTestingException.new, ::RollbarTest.success_message
|
22
|
-
end
|
23
|
-
|
24
|
-
def self.run
|
25
|
-
return unless confirmed_token?
|
26
|
-
|
27
|
-
configure_rails if defined?(Rails)
|
28
|
-
|
29
|
-
puts 'Testing manual report...'
|
30
|
-
Rollbar.error('Test error from rollbar:test')
|
31
|
-
|
32
|
-
return unless defined?(Rack::MockRequest)
|
33
|
-
|
34
|
-
protocol, app = setup_app
|
35
|
-
|
36
|
-
puts 'Processing...'
|
37
|
-
env = Rack::MockRequest.env_for("#{protocol}://www.example.com/verify", 'REMOTE_ADDR' => '127.0.0.1')
|
38
|
-
status, = app.call(env)
|
39
|
-
|
40
|
-
puts error_message unless status.to_i == 500
|
41
|
-
end
|
42
|
-
|
43
|
-
def self.configure_rails
|
44
|
-
Rails.logger = if defined?(ActiveSupport::TaggedLogging)
|
45
|
-
ActiveSupport::TaggedLogging.new(Logger.new(STDOUT))
|
46
|
-
else
|
47
|
-
Logger.new(STDOUT)
|
48
|
-
end
|
49
|
-
|
50
|
-
Rails.logger.level = Logger::DEBUG
|
51
|
-
Rollbar.preconfigure do |config|
|
52
|
-
config.logger = Rails.logger
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
def self.confirmed_token?
|
57
|
-
return true if Rollbar.configuration.access_token
|
58
|
-
|
59
|
-
puts token_error_message
|
60
|
-
|
61
|
-
false
|
62
|
-
end
|
63
|
-
|
64
|
-
def self.authlogic_config
|
65
|
-
# from http://stackoverflow.com/questions/5270835/authlogic-activation-problems
|
66
|
-
return unless defined?(Authlogic)
|
67
|
-
|
68
|
-
Authlogic::Session::Base.controller = Authlogic::ControllerAdapters::RailsAdapter.new(self)
|
69
|
-
end
|
70
|
-
|
71
|
-
def self.setup_app
|
72
|
-
puts 'Setting up the test app.'
|
73
|
-
|
74
|
-
if defined?(Rails)
|
75
|
-
app = rails_app
|
5
|
+
rollbar_dir = Gem.loaded_specs['rollbar'].full_gem_path
|
6
|
+
require "#{rollbar_dir}/lib/rollbar/rollbar_test"
|
76
7
|
|
77
|
-
|
78
|
-
|
79
|
-
authlogic_config
|
80
|
-
|
81
|
-
[rails_protocol(app), app]
|
82
|
-
else
|
83
|
-
['http', rack_app]
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
def self.rails_app
|
88
|
-
# The setup below is needed for Rails 5.x, but not for Rails 4.x and below.
|
89
|
-
# (And fails on Rails 4.x in various ways depending on the exact version.)
|
90
|
-
return Rails.application if Rails.version < '5.0.0'
|
91
|
-
|
92
|
-
# Spring now runs by default in development on all new Rails installs. This causes
|
93
|
-
# the new `/verify` route to not get picked up if `config.cache_classes == false`
|
94
|
-
# which is also a default in development env.
|
95
|
-
#
|
96
|
-
# `config.cache_classes` needs to be set, but the only possible time is at app load,
|
97
|
-
# so here we clone the default app with an updated config.
|
98
|
-
#
|
99
|
-
config = Rails.application.config
|
100
|
-
config.cache_classes = true
|
101
|
-
|
102
|
-
# Make a copy of the app, so the config can be updated.
|
103
|
-
Rails.application.class.name.constantize.new(:config => config)
|
104
|
-
end
|
105
|
-
|
106
|
-
def self.draw_rails_route(app)
|
107
|
-
app.routes_reloader.execute_if_updated
|
108
|
-
app.routes.draw do
|
109
|
-
get 'verify' => 'rollbar_test#verify', :as => 'verify'
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
def self.rails_protocol(app)
|
114
|
-
defined?(app.config.force_ssl && app.config.force_ssl) ? 'https' : 'http'
|
115
|
-
end
|
116
|
-
|
117
|
-
def self.rack_app
|
118
|
-
Class.new do
|
119
|
-
include RollbarTest
|
120
|
-
|
121
|
-
def self.call(_env)
|
122
|
-
new.test_rollbar
|
123
|
-
end
|
124
|
-
end
|
125
|
-
end
|
126
|
-
|
127
|
-
def self.token_error_message
|
128
|
-
'Rollbar needs an access token configured. Check the README for instructions.'
|
129
|
-
end
|
130
|
-
|
131
|
-
def self.error_message
|
132
|
-
'Test failed! You may have a configuration issue, or you could be using a gem that\'s blocking the test. Contact support@rollbar.com if you need help troubleshooting.'
|
133
|
-
end
|
134
|
-
|
135
|
-
def self.success_message
|
136
|
-
'Testing rollbar with "rake rollbar:test". If you can see this, it works.'
|
137
|
-
end
|
138
|
-
end
|
139
|
-
|
140
|
-
class RollbarTestingException < RuntimeError; end
|
141
|
-
|
142
|
-
if defined?(Rails)
|
143
|
-
class RollbarTestController < ActionController::Base # :nodoc:
|
144
|
-
include RollbarTest
|
145
|
-
|
146
|
-
def verify
|
147
|
-
test_rollbar
|
148
|
-
end
|
149
|
-
|
150
|
-
def logger
|
151
|
-
nil
|
152
|
-
end
|
8
|
+
RollbarTest.run
|
153
9
|
end
|
154
10
|
end
|
@@ -210,8 +210,7 @@ module Rollbar
|
|
210
210
|
def json_request?(rack_req)
|
211
211
|
json_regex = /\bjson\b/
|
212
212
|
|
213
|
-
!!(rack_req.env['CONTENT_TYPE'] =~ json_regex
|
214
|
-
rack_req.env['HTTP_ACCEPT'] =~ json_regex)
|
213
|
+
!!(rack_req.env['CONTENT_TYPE'] =~ json_regex)
|
215
214
|
end
|
216
215
|
|
217
216
|
def rollbar_route_params(env)
|
@@ -0,0 +1,147 @@
|
|
1
|
+
require 'rollbar'
|
2
|
+
begin
|
3
|
+
require 'rack/mock'
|
4
|
+
rescue LoadError
|
5
|
+
puts 'Cannot load rack/mock'
|
6
|
+
end
|
7
|
+
require 'logger'
|
8
|
+
|
9
|
+
# Module to inject into the Rails controllers or rack apps
|
10
|
+
module RollbarTest # :nodoc:
|
11
|
+
def test_rollbar
|
12
|
+
puts 'Raising RollbarTestingException to simulate app failure.'
|
13
|
+
|
14
|
+
raise RollbarTestingException.new, ::RollbarTest.success_message
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.run
|
18
|
+
return unless confirmed_token?
|
19
|
+
|
20
|
+
configure_rails if defined?(Rails)
|
21
|
+
|
22
|
+
puts 'Testing manual report...'
|
23
|
+
Rollbar.error('Test error from rollbar:test')
|
24
|
+
|
25
|
+
return unless defined?(Rack::MockRequest)
|
26
|
+
|
27
|
+
protocol, app = setup_app
|
28
|
+
|
29
|
+
puts 'Processing...'
|
30
|
+
env = Rack::MockRequest.env_for("#{protocol}://www.example.com/verify", 'REMOTE_ADDR' => '127.0.0.1')
|
31
|
+
status, = app.call(env)
|
32
|
+
|
33
|
+
puts error_message unless status.to_i == 500
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.configure_rails
|
37
|
+
Rails.logger = if defined?(ActiveSupport::TaggedLogging)
|
38
|
+
ActiveSupport::TaggedLogging.new(Logger.new(STDOUT))
|
39
|
+
else
|
40
|
+
Logger.new(STDOUT)
|
41
|
+
end
|
42
|
+
|
43
|
+
Rails.logger.level = Logger::DEBUG
|
44
|
+
Rollbar.preconfigure do |config|
|
45
|
+
config.logger = Rails.logger
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.confirmed_token?
|
50
|
+
return true if Rollbar.configuration.access_token
|
51
|
+
|
52
|
+
puts token_error_message
|
53
|
+
|
54
|
+
false
|
55
|
+
end
|
56
|
+
|
57
|
+
def self.authlogic_config
|
58
|
+
# from http://stackoverflow.com/questions/5270835/authlogic-activation-problems
|
59
|
+
return unless defined?(Authlogic)
|
60
|
+
|
61
|
+
Authlogic::Session::Base.controller = Authlogic::ControllerAdapters::RailsAdapter.new(self)
|
62
|
+
end
|
63
|
+
|
64
|
+
def self.setup_app
|
65
|
+
puts 'Setting up the test app.'
|
66
|
+
|
67
|
+
if defined?(Rails)
|
68
|
+
app = rails_app
|
69
|
+
|
70
|
+
draw_rails_route(app)
|
71
|
+
|
72
|
+
authlogic_config
|
73
|
+
|
74
|
+
[rails_protocol(app), app]
|
75
|
+
else
|
76
|
+
['http', rack_app]
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def self.rails_app
|
81
|
+
# The setup below is needed for Rails 5.x, but not for Rails 4.x and below.
|
82
|
+
# (And fails on Rails 4.x in various ways depending on the exact version.)
|
83
|
+
return Rails.application if Rails.version < '5.0.0'
|
84
|
+
|
85
|
+
# Spring now runs by default in development on all new Rails installs. This causes
|
86
|
+
# the new `/verify` route to not get picked up if `config.cache_classes == false`
|
87
|
+
# which is also a default in development env.
|
88
|
+
#
|
89
|
+
# `config.cache_classes` needs to be set, but the only possible time is at app load,
|
90
|
+
# so here we clone the default app with an updated config.
|
91
|
+
#
|
92
|
+
config = Rails.application.config
|
93
|
+
config.cache_classes = true
|
94
|
+
|
95
|
+
# Make a copy of the app, so the config can be updated.
|
96
|
+
Rails.application.class.name.constantize.new(:config => config)
|
97
|
+
end
|
98
|
+
|
99
|
+
def self.draw_rails_route(app)
|
100
|
+
app.routes_reloader.execute_if_updated
|
101
|
+
app.routes.draw do
|
102
|
+
get 'verify' => 'rollbar_test#verify', :as => 'verify'
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
def self.rails_protocol(app)
|
107
|
+
defined?(app.config.force_ssl && app.config.force_ssl) ? 'https' : 'http'
|
108
|
+
end
|
109
|
+
|
110
|
+
def self.rack_app
|
111
|
+
Class.new do
|
112
|
+
include RollbarTest
|
113
|
+
|
114
|
+
def self.call(_env)
|
115
|
+
new.test_rollbar
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
def self.token_error_message
|
121
|
+
'Rollbar needs an access token configured. Check the README for instructions.'
|
122
|
+
end
|
123
|
+
|
124
|
+
def self.error_message
|
125
|
+
'Test failed! You may have a configuration issue, or you could be using a gem that\'s blocking the test. Contact support@rollbar.com if you need help troubleshooting.'
|
126
|
+
end
|
127
|
+
|
128
|
+
def self.success_message
|
129
|
+
'Testing rollbar with "rake rollbar:test". If you can see this, it works.'
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
class RollbarTestingException < RuntimeError; end
|
134
|
+
|
135
|
+
if defined?(Rails)
|
136
|
+
class RollbarTestController < ActionController::Base # :nodoc:
|
137
|
+
include RollbarTest
|
138
|
+
|
139
|
+
def verify
|
140
|
+
test_rollbar
|
141
|
+
end
|
142
|
+
|
143
|
+
def logger
|
144
|
+
nil
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|