rollbar 3.1.1 → 3.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +18 -1
- data/.rubocop.yml +81 -34
- data/Gemfile +17 -10
- data/README.md +1 -1
- data/data/rollbar.snippet.js +1 -1
- data/gemfiles/rails30.gemfile +11 -12
- data/gemfiles/rails31.gemfile +12 -13
- data/gemfiles/rails32.gemfile +5 -6
- data/gemfiles/rails40.gemfile +3 -5
- data/gemfiles/rails41.gemfile +3 -6
- data/gemfiles/rails42.gemfile +5 -10
- data/gemfiles/rails50.gemfile +9 -10
- data/gemfiles/rails51.gemfile +8 -9
- data/gemfiles/rails52.gemfile +6 -5
- data/gemfiles/rails60.gemfile +7 -12
- data/gemfiles/rails61.gemfile +54 -0
- data/lib/generators/rollbar/rollbar_generator.rb +18 -14
- data/lib/generators/rollbar/templates/{initializer.rb → initializer.erb} +0 -0
- data/lib/rails/rollbar_runner.rb +12 -5
- data/lib/rollbar/capistrano.rb +16 -8
- data/lib/rollbar/capistrano3.rb +8 -2
- data/lib/rollbar/capistrano_tasks.rb +37 -10
- data/lib/rollbar/configuration.rb +114 -90
- data/lib/rollbar/delay/shoryuken.rb +4 -3
- data/lib/rollbar/delay/sidekiq.rb +3 -1
- data/lib/rollbar/delay/sucker_punch.rb +1 -2
- data/lib/rollbar/delay/thread.rb +3 -2
- data/lib/rollbar/deploy.rb +6 -7
- data/lib/rollbar/encoding/encoder.rb +7 -3
- data/lib/rollbar/exception_reporter.rb +17 -8
- data/lib/rollbar/item/backtrace.rb +10 -8
- data/lib/rollbar/item/frame.rb +6 -5
- data/lib/rollbar/item/locals.rb +3 -2
- data/lib/rollbar/item.rb +47 -38
- data/lib/rollbar/json.rb +1 -1
- data/lib/rollbar/lazy_store.rb +1 -3
- data/lib/rollbar/logger.rb +2 -0
- data/lib/rollbar/logger_proxy.rb +3 -1
- data/lib/rollbar/middleware/js.rb +58 -36
- data/lib/rollbar/middleware/rack/builder.rb +3 -3
- data/lib/rollbar/middleware/rack/test_session.rb +3 -3
- data/lib/rollbar/middleware/rack.rb +4 -4
- data/lib/rollbar/middleware/rails/rollbar.rb +9 -6
- data/lib/rollbar/middleware/rails/show_exceptions.rb +8 -4
- data/lib/rollbar/notifier/trace_with_bindings.rb +4 -2
- data/lib/rollbar/notifier.rb +179 -133
- data/lib/rollbar/plugin.rb +8 -8
- data/lib/rollbar/plugins/active_job.rb +11 -2
- data/lib/rollbar/plugins/delayed_job/plugin.rb +10 -3
- data/lib/rollbar/plugins/goalie.rb +27 -16
- data/lib/rollbar/plugins/rails/controller_methods.rb +18 -14
- data/lib/rollbar/plugins/rails/railtie30.rb +2 -1
- data/lib/rollbar/plugins/rails/railtie32.rb +2 -1
- data/lib/rollbar/plugins/rails/railtie_mixin.rb +2 -2
- data/lib/rollbar/plugins/rails.rb +5 -2
- data/lib/rollbar/plugins/rake.rb +2 -1
- data/lib/rollbar/plugins/sidekiq/plugin.rb +37 -20
- data/lib/rollbar/plugins/sidekiq.rb +1 -1
- data/lib/rollbar/plugins/thread.rb +8 -7
- data/lib/rollbar/plugins/validations.rb +3 -1
- data/lib/rollbar/rake_tasks.rb +0 -1
- data/lib/rollbar/request_data_extractor.rb +38 -17
- data/lib/rollbar/rollbar_test.rb +3 -1
- data/lib/rollbar/scrubbers/params.rb +13 -7
- data/lib/rollbar/scrubbers/url.rb +48 -14
- data/lib/rollbar/scrubbers.rb +1 -1
- data/lib/rollbar/truncation/remove_any_key_strategy.rb +4 -1
- data/lib/rollbar/truncation/remove_extra_strategy.rb +3 -1
- data/lib/rollbar/util/hash.rb +14 -7
- data/lib/rollbar/util/ip_anonymizer.rb +1 -1
- data/lib/rollbar/util.rb +19 -13
- data/lib/rollbar/version.rb +1 -1
- data/lib/rollbar.rb +12 -7
- data/lib/tasks/benchmark.rake +2 -1
- data/rollbar.gemspec +3 -1
- metadata +5 -5
data/gemfiles/rails51.gemfile
CHANGED
@@ -2,7 +2,7 @@ require 'rubygems/version'
|
|
2
2
|
|
3
3
|
source 'https://rubygems.org'
|
4
4
|
|
5
|
-
is_jruby = defined?(JRUBY_VERSION) || (defined?(RUBY_ENGINE) && 'jruby'
|
5
|
+
is_jruby = defined?(JRUBY_VERSION) || (defined?(RUBY_ENGINE) && RUBY_ENGINE == 'jruby')
|
6
6
|
|
7
7
|
gem 'activerecord-jdbcsqlite3-adapter', :platform => :jruby
|
8
8
|
gem 'jruby-openssl', :platform => :jruby
|
@@ -12,10 +12,10 @@ gem 'rails', '~> 5.1.7'
|
|
12
12
|
gem 'sqlite3', '< 1.4.0', :platform => [:ruby, :mswin, :mingw]
|
13
13
|
|
14
14
|
gem 'rspec-core', '~> 3.5.0.beta3'
|
15
|
-
gem 'rspec-rails', '~> 3.5.0.beta3'
|
16
|
-
gem 'rspec-support', '~> 3.5.0.beta3'
|
17
15
|
gem 'rspec-expectations', '~> 3.5.0.beta3'
|
18
16
|
gem 'rspec-mocks', '~> 3.5.0.beta3'
|
17
|
+
gem 'rspec-rails', '~> 3.5.0.beta3'
|
18
|
+
gem 'rspec-support', '~> 3.5.0.beta3'
|
19
19
|
|
20
20
|
gem 'rake'
|
21
21
|
|
@@ -25,27 +25,26 @@ platforms :rbx do
|
|
25
25
|
gem 'minitest'
|
26
26
|
gem 'racc'
|
27
27
|
gem 'rubinius-developer_tools'
|
28
|
-
gem 'rubysl', '~> 2.0'
|
28
|
+
gem 'rubysl', '~> 2.0' if RUBY_VERSION.start_with?('2')
|
29
29
|
end
|
30
30
|
|
31
31
|
gem 'capistrano', :require => false
|
32
|
-
gem 'sucker_punch', '~> 2.0'
|
33
32
|
gem 'codacy-coverage'
|
34
33
|
gem 'simplecov', '<= 0.17.1'
|
34
|
+
gem 'sucker_punch', '~> 2.0'
|
35
35
|
|
36
|
-
if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.3')
|
37
|
-
gem 'rack', '2.1.2'
|
38
|
-
end
|
36
|
+
gem 'rack', '2.1.2' if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.3')
|
39
37
|
|
40
38
|
# We need last sinatra that uses rack 2.1.x
|
41
39
|
gem 'sinatra', :git => 'https://github.com/sinatra/sinatra', :tag => 'v2.0.8'
|
42
40
|
|
43
|
-
gem 'database_cleaner'
|
41
|
+
gem 'database_cleaner', '~> 1.8.4'
|
44
42
|
gem 'delayed_job', :require => false
|
45
43
|
gem 'generator_spec'
|
46
44
|
gem 'girl_friday', '>= 0.11.1'
|
47
45
|
gem 'redis', '<= 3.3.5'
|
48
46
|
gem 'resque'
|
47
|
+
gem 'secure_headers', '~> 6.3.2', :require => false
|
49
48
|
|
50
49
|
unless is_jruby
|
51
50
|
# JRuby doesn't support fork, which is required for this test helper.
|
data/gemfiles/rails52.gemfile
CHANGED
@@ -2,7 +2,7 @@ require 'rubygems/version'
|
|
2
2
|
|
3
3
|
source 'https://rubygems.org'
|
4
4
|
|
5
|
-
is_jruby = defined?(JRUBY_VERSION) || (defined?(RUBY_ENGINE) && 'jruby'
|
5
|
+
is_jruby = defined?(JRUBY_VERSION) || (defined?(RUBY_ENGINE) && RUBY_ENGINE == 'jruby')
|
6
6
|
|
7
7
|
gem 'activerecord-jdbcsqlite3-adapter', :platform => :jruby
|
8
8
|
gem 'jruby-openssl', :platform => :jruby
|
@@ -10,10 +10,10 @@ gem 'rails', '~> 5.2.3'
|
|
10
10
|
gem 'sqlite3', '< 1.4.0', :platform => [:ruby, :mswin, :mingw]
|
11
11
|
|
12
12
|
gem 'rspec-core', '~> 3.8.0'
|
13
|
-
gem 'rspec-rails', '~> 3.8.0'
|
14
|
-
gem 'rspec-support', '~> 3.8.0'
|
15
13
|
gem 'rspec-expectations', '~> 3.8.0'
|
16
14
|
gem 'rspec-mocks', '~> 3.8.0'
|
15
|
+
gem 'rspec-rails', '~> 3.8.0'
|
16
|
+
gem 'rspec-support', '~> 3.8.0'
|
17
17
|
|
18
18
|
gem 'rake'
|
19
19
|
|
@@ -23,7 +23,7 @@ platforms :rbx do
|
|
23
23
|
gem 'minitest'
|
24
24
|
gem 'racc'
|
25
25
|
gem 'rubinius-developer_tools'
|
26
|
-
gem 'rubysl', '~> 2.0'
|
26
|
+
gem 'rubysl', '~> 2.0' if RUBY_VERSION.start_with?('2')
|
27
27
|
end
|
28
28
|
|
29
29
|
gem 'sucker_punch', '~> 2.0'
|
@@ -31,13 +31,14 @@ gem 'sucker_punch', '~> 2.0'
|
|
31
31
|
# We need last sinatra that uses rack 2.x
|
32
32
|
gem 'sinatra', :git => 'https://github.com/sinatra/sinatra'
|
33
33
|
|
34
|
-
gem 'database_cleaner'
|
35
34
|
gem 'codacy-coverage'
|
35
|
+
gem 'database_cleaner'
|
36
36
|
gem 'delayed_job', :require => false
|
37
37
|
gem 'generator_spec'
|
38
38
|
gem 'girl_friday', '>= 0.11.1'
|
39
39
|
gem 'redis'
|
40
40
|
gem 'resque'
|
41
|
+
gem 'secure_headers', '~> 6.3.2', :require => false
|
41
42
|
gem 'simplecov', '<= 0.17.1'
|
42
43
|
|
43
44
|
unless is_jruby
|
data/gemfiles/rails60.gemfile
CHANGED
@@ -1,21 +1,15 @@
|
|
1
|
-
|
2
1
|
require 'rubygems/version'
|
3
2
|
|
4
3
|
source 'https://rubygems.org'
|
5
4
|
|
6
|
-
is_jruby = defined?(JRUBY_VERSION) || (defined?(RUBY_ENGINE) && 'jruby'
|
5
|
+
is_jruby = defined?(JRUBY_VERSION) || (defined?(RUBY_ENGINE) && RUBY_ENGINE == 'jruby')
|
7
6
|
|
8
7
|
gem 'activerecord-jdbcsqlite3-adapter', :platform => :jruby
|
9
8
|
gem 'jruby-openssl', :platform => :jruby
|
10
|
-
gem 'rails', '6.0.2
|
9
|
+
gem 'rails', '~> 6.0.2'
|
11
10
|
gem 'sqlite3', '~> 1.4', :platform => [:ruby, :mswin, :mingw]
|
12
11
|
|
13
|
-
gem 'rspec-
|
14
|
-
gem 'rspec-support', '~> 3.8.0'
|
15
|
-
gem 'rspec-expectations', '~> 3.8.0'
|
16
|
-
gem 'rspec-mocks', '~> 3.8.0'
|
17
|
-
# TODO: update this when 4.x becomes available on Rubygems
|
18
|
-
gem 'rspec-rails', :git => 'https://github.com/rspec/rspec-rails', :ref => 'v4.0.0.beta2' # rubocop:disable Bundler/DuplicatedGem
|
12
|
+
gem 'rspec-rails', '~> 4.0.2'
|
19
13
|
|
20
14
|
gem 'rake'
|
21
15
|
|
@@ -25,7 +19,7 @@ platforms :rbx do
|
|
25
19
|
gem 'minitest'
|
26
20
|
gem 'racc'
|
27
21
|
gem 'rubinius-developer_tools'
|
28
|
-
gem 'rubysl', '~> 2.0'
|
22
|
+
gem 'rubysl', '~> 2.0' if RUBY_VERSION.start_with?('2')
|
29
23
|
end
|
30
24
|
|
31
25
|
gem 'sucker_punch', '~> 2.0'
|
@@ -33,13 +27,14 @@ gem 'sucker_punch', '~> 2.0'
|
|
33
27
|
# We need last sinatra that uses rack 2.x
|
34
28
|
gem 'sinatra', :git => 'https://github.com/sinatra/sinatra'
|
35
29
|
|
36
|
-
gem 'database_cleaner'
|
37
30
|
gem 'codacy-coverage'
|
38
|
-
gem '
|
31
|
+
gem 'database_cleaner'
|
32
|
+
gem 'delayed_job', '4.1.9', :require => false
|
39
33
|
gem 'generator_spec'
|
40
34
|
gem 'girl_friday', '>= 0.11.1'
|
41
35
|
gem 'redis'
|
42
36
|
gem 'resque'
|
37
|
+
gem 'secure_headers', '~> 6.3.2', :require => false
|
43
38
|
gem 'simplecov'
|
44
39
|
|
45
40
|
unless is_jruby
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'rubygems/version'
|
2
|
+
|
3
|
+
source 'https://rubygems.org'
|
4
|
+
|
5
|
+
is_jruby = defined?(JRUBY_VERSION) || (defined?(RUBY_ENGINE) && RUBY_ENGINE == 'jruby')
|
6
|
+
|
7
|
+
gem 'activerecord-jdbcsqlite3-adapter', :platform => :jruby
|
8
|
+
gem 'jruby-openssl', :platform => :jruby
|
9
|
+
gem 'rails', '~> 6.1.3'
|
10
|
+
gem 'sqlite3', '~> 1.4', :platform => [:ruby, :mswin, :mingw]
|
11
|
+
|
12
|
+
gem 'rspec-rails', '~> 4.0.2'
|
13
|
+
|
14
|
+
gem 'rake'
|
15
|
+
|
16
|
+
gem 'sidekiq', '>= 2.13.0'
|
17
|
+
|
18
|
+
platforms :rbx do
|
19
|
+
gem 'minitest'
|
20
|
+
gem 'racc'
|
21
|
+
gem 'rubinius-developer_tools'
|
22
|
+
gem 'rubysl', '~> 2.0' if RUBY_VERSION.start_with?('2')
|
23
|
+
end
|
24
|
+
|
25
|
+
gem 'sucker_punch', '~> 2.0'
|
26
|
+
|
27
|
+
# We need last sinatra that uses rack 2.x
|
28
|
+
gem 'sinatra', :git => 'https://github.com/sinatra/sinatra'
|
29
|
+
|
30
|
+
gem 'codacy-coverage'
|
31
|
+
gem 'database_cleaner'
|
32
|
+
gem 'delayed_job', '4.1.9', :require => false
|
33
|
+
gem 'generator_spec'
|
34
|
+
gem 'girl_friday', '>= 0.11.1'
|
35
|
+
gem 'redis'
|
36
|
+
gem 'resque'
|
37
|
+
gem 'secure_headers', '~> 6.3.2', :require => false
|
38
|
+
gem 'simplecov'
|
39
|
+
|
40
|
+
unless is_jruby
|
41
|
+
# JRuby doesn't support fork, which is required for this test helper.
|
42
|
+
gem 'rspec-command'
|
43
|
+
end
|
44
|
+
|
45
|
+
gem 'mime-types'
|
46
|
+
|
47
|
+
gem 'webmock', :require => false
|
48
|
+
|
49
|
+
gem 'aws-sdk-sqs'
|
50
|
+
gem 'shoryuken'
|
51
|
+
|
52
|
+
gem 'capistrano', :require => false
|
53
|
+
|
54
|
+
gemspec :path => '../'
|
@@ -5,7 +5,8 @@ require 'generators/rollbar/rollbar_generator'
|
|
5
5
|
module Rollbar
|
6
6
|
module Generators
|
7
7
|
class RollbarGenerator < ::Rails::Generators::Base
|
8
|
-
argument :access_token, :type => :string, :banner => 'access_token',
|
8
|
+
argument :access_token, :type => :string, :banner => 'access_token',
|
9
|
+
:default => :use_env_sentinel
|
9
10
|
|
10
11
|
source_root File.expand_path(File.join(File.dirname(__FILE__), 'templates'))
|
11
12
|
|
@@ -13,32 +14,35 @@ module Rollbar
|
|
13
14
|
say 'creating initializer...'
|
14
15
|
if access_token_configured?
|
15
16
|
say "It looks like you've already configured Rollbar."
|
16
|
-
say 'To re-create the config file, remove it first:
|
17
|
+
say 'To re-create the config file, remove it first: ' \
|
18
|
+
'config/initializers/rollbar.rb'
|
17
19
|
exit
|
18
20
|
end
|
19
21
|
|
20
22
|
begin
|
21
23
|
require 'ey_config'
|
22
24
|
rescue LoadError
|
25
|
+
# Skip loading
|
23
26
|
end
|
24
27
|
|
25
28
|
if defined? EY::Config
|
26
29
|
say 'Access token will be read from Engine Yard configuration'
|
30
|
+
elsif access_token === :use_env_sentinel
|
31
|
+
say 'Generator run without an access token; assuming you want to ' \
|
32
|
+
'configure using an environment variable.'
|
33
|
+
say "You'll need to add an environment variable ROLLBAR_ACCESS_TOKEN " \
|
34
|
+
'with your access token:'
|
35
|
+
say "\n$ export ROLLBAR_ACCESS_TOKEN=yourtokenhere"
|
36
|
+
say "\nIf that's not what you wanted to do:"
|
37
|
+
say "\n$ rm config/initializers/rollbar.rb"
|
38
|
+
say '$ rails generate rollbar yourtokenhere'
|
39
|
+
say "\n"
|
27
40
|
else
|
28
|
-
|
29
|
-
say 'Generator run without an access token; assuming you want to configure using an environment variable.'
|
30
|
-
say "You'll need to add an environment variable ROLLBAR_ACCESS_TOKEN with your access token:"
|
31
|
-
say "\n$ export ROLLBAR_ACCESS_TOKEN=yourtokenhere"
|
32
|
-
say "\nIf that's not what you wanted to do:"
|
33
|
-
say "\n$ rm config/initializers/rollbar.rb"
|
34
|
-
say '$ rails generate rollbar yourtokenhere'
|
35
|
-
say "\n"
|
36
|
-
else
|
37
|
-
say 'access token: ' << access_token
|
38
|
-
end
|
41
|
+
say 'access token: ' << access_token
|
39
42
|
end
|
40
43
|
|
41
|
-
template 'initializer.
|
44
|
+
template 'initializer.erb', 'config/initializers/rollbar.rb',
|
45
|
+
:assigns => { :access_token => access_token_expr }
|
42
46
|
|
43
47
|
# TODO: run rake test task
|
44
48
|
end
|
File without changes
|
data/lib/rails/rollbar_runner.rb
CHANGED
@@ -4,7 +4,10 @@ require 'rollbar'
|
|
4
4
|
# Rails.root is not present here.
|
5
5
|
# RSpec needs ENV['DUMMYAPP_PATH'] in order to have a valid path.
|
6
6
|
# Dir.pwd is used in normal operation.
|
7
|
-
APP_PATH = File.expand_path(
|
7
|
+
APP_PATH = File.expand_path(
|
8
|
+
'config/application',
|
9
|
+
(ENV['DUMMYAPP_PATH'] || Dir.pwd)
|
10
|
+
)
|
8
11
|
|
9
12
|
module Rails
|
10
13
|
class RollbarRunner
|
@@ -49,9 +52,9 @@ module Rails
|
|
49
52
|
def legacy_runner
|
50
53
|
string_to_eval = File.read(runner_path)
|
51
54
|
|
52
|
-
::Rails.module_eval(<<-
|
55
|
+
::Rails.module_eval(<<-FILE, __FILE__, __LINE__ + 1)
|
53
56
|
#{string_to_eval}
|
54
|
-
|
57
|
+
FILE
|
55
58
|
end
|
56
59
|
|
57
60
|
def rails5_runner
|
@@ -68,11 +71,15 @@ module Rails
|
|
68
71
|
end
|
69
72
|
|
70
73
|
def runner_path
|
71
|
-
railties_gem_dir
|
74
|
+
"#{railties_gem_dir}/lib/rails/commands/runner.rb"
|
72
75
|
end
|
73
76
|
|
74
77
|
def railties_gem
|
75
|
-
resolver_class = Gem::Specification.respond_to?(:find_by_name)
|
78
|
+
resolver_class = if Gem::Specification.respond_to?(:find_by_name)
|
79
|
+
GemResolver
|
80
|
+
else
|
81
|
+
LegacyGemResolver
|
82
|
+
end
|
76
83
|
gem = resolver_class.new.railties_gem
|
77
84
|
|
78
85
|
abort 'railties gem not found' unless gem
|
data/lib/rollbar/capistrano.rb
CHANGED
@@ -34,7 +34,11 @@ module Rollbar
|
|
34
34
|
_cset(:rollbar_role) { :app }
|
35
35
|
_cset(:rollbar_user) { ENV['USER'] || ENV['USERNAME'] }
|
36
36
|
_cset(:rollbar_env) { fetch(:rails_env, 'production') }
|
37
|
-
_cset(:rollbar_token)
|
37
|
+
_cset(:rollbar_token) do
|
38
|
+
abort(
|
39
|
+
"Please specify the Rollbar access token, set :rollbar_token, 'your token'"
|
40
|
+
)
|
41
|
+
end
|
38
42
|
_cset(:rollbar_revision) { real_revision }
|
39
43
|
_cset(:rollbar_comment) { nil }
|
40
44
|
end
|
@@ -51,7 +55,9 @@ module Rollbar
|
|
51
55
|
:task => :deploy_started,
|
52
56
|
:configuration => configuration
|
53
57
|
) do
|
54
|
-
::Rollbar::CapistranoTasks.deploy_started(
|
58
|
+
::Rollbar::CapistranoTasks.deploy_started(
|
59
|
+
configuration, configuration.logger, configuration.dry_run
|
60
|
+
)
|
55
61
|
end
|
56
62
|
end
|
57
63
|
|
@@ -61,17 +67,17 @@ module Rollbar
|
|
61
67
|
:task => :deploy_succeeded,
|
62
68
|
:configuration => configuration
|
63
69
|
) do
|
64
|
-
::Rollbar::CapistranoTasks.deploy_succeeded(
|
70
|
+
::Rollbar::CapistranoTasks.deploy_succeeded(
|
71
|
+
configuration, configuration.logger, configuration.dry_run
|
72
|
+
)
|
65
73
|
end
|
66
74
|
end
|
67
75
|
|
68
|
-
def load_task(configuration:, desc:, task
|
76
|
+
def load_task(configuration:, desc:, task:, &block)
|
69
77
|
configuration.load do
|
70
78
|
namespace :rollbar do
|
71
79
|
desc(desc)
|
72
|
-
task(task)
|
73
|
-
yield
|
74
|
-
end
|
80
|
+
task(task, &block)
|
75
81
|
end
|
76
82
|
end
|
77
83
|
end
|
@@ -79,4 +85,6 @@ module Rollbar
|
|
79
85
|
end
|
80
86
|
end
|
81
87
|
|
82
|
-
|
88
|
+
if Capistrano::Configuration.instance
|
89
|
+
Rollbar::Capistrano2.load_into(Capistrano::Configuration.instance)
|
90
|
+
end
|
data/lib/rollbar/capistrano3.rb
CHANGED
@@ -8,7 +8,10 @@ require 'rollbar/capistrano_tasks'
|
|
8
8
|
|
9
9
|
namespace :rollbar do
|
10
10
|
# dry_run? wasn't introduced till Capistrano 3.5.0; use the old fetch(:sshkit_backed)
|
11
|
-
set :dry_run, (proc {
|
11
|
+
set :dry_run, (proc {
|
12
|
+
::Capistrano::Configuration.env.fetch(:sshkit_backend) ==
|
13
|
+
::SSHKit::Backend::Printer
|
14
|
+
})
|
12
15
|
|
13
16
|
desc 'Send deployment started notification to Rollbar.'
|
14
17
|
task :deploy_started do
|
@@ -49,7 +52,10 @@ namespace :load do
|
|
49
52
|
task :defaults do
|
50
53
|
set :rollbar_user, (proc { fetch :local_user, ENV['USER'] || ENV['USERNAME'] })
|
51
54
|
set :rollbar_env, (proc { fetch :rails_env, 'production' })
|
52
|
-
set :rollbar_token, (proc {
|
55
|
+
set :rollbar_token, (proc {
|
56
|
+
abort 'Please specify the Rollbar access token, ' \
|
57
|
+
"set :rollbar_token, 'your token'"
|
58
|
+
})
|
53
59
|
set :rollbar_role, (proc { :app })
|
54
60
|
set :rollbar_revision, (proc { fetch :current_revision })
|
55
61
|
end
|
@@ -13,23 +13,31 @@ module Rollbar
|
|
13
13
|
capistrano.set(:rollbar_deploy_id, 123) if dry_run
|
14
14
|
|
15
15
|
skip_in_dry_run(logger, dry_run) do
|
16
|
-
if result[:success] &&
|
16
|
+
if result[:success] &&
|
17
|
+
(deploy_id = result[:data] &&
|
18
|
+
result[:data][:deploy_id])
|
17
19
|
capistrano.set :rollbar_deploy_id, deploy_id
|
18
20
|
else
|
19
|
-
|
21
|
+
message = format_message('Unable to report deploy to Rollbar',
|
22
|
+
result[:message])
|
23
|
+
log_error(logger, message)
|
20
24
|
end
|
21
25
|
end
|
22
26
|
end
|
23
27
|
end
|
24
28
|
|
25
29
|
def deploy_succeeded(capistrano, logger, dry_run)
|
26
|
-
deploy_update(
|
30
|
+
deploy_update(
|
31
|
+
capistrano, logger, dry_run,
|
32
|
+
:desc => 'Setting deployment status to `succeeded` in Rollbar'
|
33
|
+
) do
|
27
34
|
report_deploy_succeeded(capistrano, dry_run)
|
28
35
|
end
|
29
36
|
end
|
30
37
|
|
31
38
|
def deploy_failed(capistrano, logger, dry_run)
|
32
|
-
deploy_update(capistrano, logger, dry_run,
|
39
|
+
deploy_update(capistrano, logger, dry_run,
|
40
|
+
:desc => 'Setting deployment status to `failed` in Rollbar') do
|
33
41
|
report_deploy_failed(capistrano, dry_run)
|
34
42
|
end
|
35
43
|
end
|
@@ -40,9 +48,8 @@ module Rollbar
|
|
40
48
|
capistrano_300_warning(logger)
|
41
49
|
logger.info opts[:desc] if opts[:desc]
|
42
50
|
yield
|
43
|
-
|
44
51
|
rescue StandardError => e
|
45
|
-
logger
|
52
|
+
log_error logger, "Error reporting to Rollbar: #{e.inspect}"
|
46
53
|
end
|
47
54
|
|
48
55
|
def deploy_update(capistrano, logger, dry_run, opts = {})
|
@@ -56,7 +63,9 @@ module Rollbar
|
|
56
63
|
if result[:success]
|
57
64
|
logger.info 'Updated deploy status in Rollbar'
|
58
65
|
else
|
59
|
-
|
66
|
+
message = format_message('Unable to update deploy status in Rollbar',
|
67
|
+
result[:message])
|
68
|
+
log_error(logger, message)
|
60
69
|
end
|
61
70
|
end
|
62
71
|
end
|
@@ -64,7 +73,9 @@ module Rollbar
|
|
64
73
|
end
|
65
74
|
|
66
75
|
def capistrano_300_warning(logger)
|
67
|
-
|
76
|
+
unless ::Capistrano.const_defined?('VERSION') && ::Capistrano::VERSION =~ /^3\.0/
|
77
|
+
return
|
78
|
+
end
|
68
79
|
|
69
80
|
logger.warn('You need to upgrade capistrano to >= 3.1 version in order'\
|
70
81
|
'to correctly report deploys to Rollbar. (On 3.0, the reported revision'\
|
@@ -117,7 +128,8 @@ module Rollbar
|
|
117
128
|
if capistrano.fetch(:rollbar_deploy_id)
|
118
129
|
yield
|
119
130
|
else
|
120
|
-
logger
|
131
|
+
log_error logger,
|
132
|
+
'Failed to update the deploy in Rollbar. No deploy id available.'
|
121
133
|
end
|
122
134
|
end
|
123
135
|
|
@@ -130,10 +142,25 @@ module Rollbar
|
|
130
142
|
end
|
131
143
|
|
132
144
|
def debug_request_response(logger, result)
|
133
|
-
# NOTE: in Capistrano debug messages go to log/capistrano.log but not to
|
145
|
+
# NOTE: in Capistrano debug messages go to log/capistrano.log but not to
|
146
|
+
# stdout even if log_level == :debug
|
134
147
|
logger.debug result[:request_info]
|
135
148
|
logger.debug result[:response_info] if result[:response_info]
|
136
149
|
end
|
150
|
+
|
151
|
+
def format_message(*args)
|
152
|
+
args.compact.join(': ')
|
153
|
+
end
|
154
|
+
|
155
|
+
def log_error(logger, message)
|
156
|
+
# Capistrano 2.x doesn't have the #error method,
|
157
|
+
# so we use #important if #error isn't present
|
158
|
+
if logger.respond_to?(:error)
|
159
|
+
logger.error message
|
160
|
+
elsif logger.respond_to?(:important)
|
161
|
+
logger.important message
|
162
|
+
end
|
163
|
+
end
|
137
164
|
end
|
138
165
|
end
|
139
166
|
end
|