rollbar 2.18.2 → 2.19.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +15 -0
- data/.travis.yml +155 -93
- data/Gemfile +19 -13
- data/README.md +12 -0
- data/gemfiles/rails30.gemfile +17 -10
- data/gemfiles/rails31.gemfile +20 -12
- data/gemfiles/rails32.gemfile +16 -7
- data/gemfiles/rails40.gemfile +16 -5
- data/gemfiles/rails41.gemfile +15 -5
- data/gemfiles/rails42.gemfile +25 -14
- data/gemfiles/rails50.gemfile +15 -8
- data/gemfiles/rails51.gemfile +15 -8
- data/gemfiles/rails52.gemfile +62 -0
- data/gemfiles/ruby_1_8_and_1_9_2.gemfile +2 -2
- data/lib/rails/rollbar_runner.rb +16 -1
- data/lib/rollbar/capistrano.rb +71 -39
- data/lib/rollbar/capistrano3.rb +53 -1
- data/lib/rollbar/capistrano_tasks.rb +131 -0
- data/lib/rollbar/configuration.rb +13 -4
- data/lib/rollbar/delay/active_job.rb +17 -0
- data/lib/rollbar/delay/sidekiq.rb +3 -1
- data/lib/rollbar/delay/thread.rb +1 -1
- data/lib/rollbar/deploy.rb +69 -0
- data/lib/rollbar/item.rb +17 -6
- data/lib/rollbar/middleware/js.rb +25 -3
- data/lib/rollbar/middleware/js/json_value.rb +26 -0
- data/lib/rollbar/notifier.rb +32 -13
- data/lib/rollbar/plugins/active_job.rb +3 -0
- data/lib/rollbar/plugins/rails/controller_methods.rb +2 -1
- data/lib/rollbar/plugins/rails/railtie_mixin.rb +7 -1
- data/lib/rollbar/rake_tasks.rb +126 -67
- data/lib/rollbar/scrubbers/params.rb +6 -0
- data/lib/rollbar/util.rb +75 -45
- data/lib/rollbar/util/hash.rb +15 -6
- data/lib/rollbar/version.rb +1 -1
- data/rollbar.gemspec +2 -3
- metadata +9 -261
- data/lib/rollbar/tasks/rollbar.cap +0 -47
- data/spec/cacert.pem +0 -3988
- data/spec/controllers/home_controller_spec.rb +0 -480
- data/spec/delay/sidekiq_spec.rb +0 -61
- data/spec/delay/sucker_punch_spec.rb +0 -25
- data/spec/delayed/backend/test.rb +0 -140
- 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/book.rb +0 -5
- data/spec/dummyapp/app/models/post.rb +0 -9
- data/spec/dummyapp/app/models/user.rb +0 -9
- 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.ru +0 -4
- 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 -26
- 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/secrets.yml +0 -2
- 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/migrate/20161219184410_create_books.rb +0 -10
- data/spec/dummyapp/db/migrate/20161219185529_add_username_to_users.rb +0 -5
- data/spec/dummyapp/db/schema.rb +0 -41
- 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/fixtures/plugins/dummy1.rb +0 -5
- data/spec/fixtures/plugins/dummy2.rb +0 -5
- data/spec/generators/rollbar/rollbar_generator_rails30_spec.rb +0 -31
- data/spec/generators/rollbar/rollbar_generator_spec.rb +0 -51
- data/spec/requests/home_spec.rb +0 -49
- data/spec/rollbar/configuration_spec.rb +0 -74
- data/spec/rollbar/delay/delayed_job_spec.rb +0 -22
- data/spec/rollbar/delay/girl_friday_spec.rb +0 -41
- data/spec/rollbar/delay/resque_spec.rb +0 -37
- data/spec/rollbar/delay/shoryuken_spec.rb +0 -44
- data/spec/rollbar/delay/thread_spec.rb +0 -27
- data/spec/rollbar/encoding/encoder_spec.rb +0 -63
- data/spec/rollbar/item/backtrace_spec.rb +0 -26
- data/spec/rollbar/item/frame_spec.rb +0 -267
- data/spec/rollbar/item_spec.rb +0 -736
- 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 -69
- data/spec/rollbar/logger_spec.rb +0 -124
- data/spec/rollbar/middleware/js_spec.rb +0 -428
- data/spec/rollbar/middleware/sinatra_spec.rb +0 -197
- data/spec/rollbar/notifier_spec.rb +0 -67
- data/spec/rollbar/plugin_spec.rb +0 -209
- data/spec/rollbar/plugins/active_job_spec.rb +0 -45
- data/spec/rollbar/plugins/delayed_job/job_data_spec.rb +0 -48
- data/spec/rollbar/plugins/delayed_job_spec.rb +0 -129
- data/spec/rollbar/plugins/rack_spec.rb +0 -152
- data/spec/rollbar/plugins/rails_js_spec.rb +0 -19
- data/spec/rollbar/plugins/rake_spec.rb +0 -34
- data/spec/rollbar/plugins/resque/failure_spec.rb +0 -36
- data/spec/rollbar/plugins/sidekiq_spec.rb +0 -169
- data/spec/rollbar/plugins/validations_spec.rb +0 -56
- data/spec/rollbar/plugins_spec.rb +0 -68
- data/spec/rollbar/request_data_extractor_spec.rb +0 -321
- data/spec/rollbar/scrubbers/params_spec.rb +0 -598
- data/spec/rollbar/scrubbers/url_spec.rb +0 -240
- data/spec/rollbar/scrubbers_spec.rb +0 -31
- data/spec/rollbar/sidekig/clear_scope_spec.rb +0 -19
- 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/ip_anonymizer_spec.rb +0 -30
- data/spec/rollbar/util_spec.rb +0 -80
- data/spec/rollbar_bc_spec.rb +0 -380
- data/spec/rollbar_spec.rb +0 -1737
- data/spec/spec_helper.rb +0 -84
- 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/matchers.rb +0 -23
- data/spec/support/notifier_helpers.rb +0 -57
- data/spec/support/rollbar_api.rb +0 -57
- data/spec/support/secure_headers_mocks.rb +0 -83
- data/spec/support/shared_contexts.rb +0 -12
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'rubygems/version'
|
2
|
+
|
3
|
+
source 'https://rubygems.org'
|
4
|
+
|
5
|
+
is_jruby = defined?(JRUBY_VERSION) || (defined?(RUBY_ENGINE) && 'jruby' == RUBY_ENGINE)
|
6
|
+
|
7
|
+
gem 'appraisal'
|
8
|
+
gem 'activerecord-jdbcsqlite3-adapter', :platform => :jruby
|
9
|
+
gem 'jruby-openssl', :platform => :jruby
|
10
|
+
gem 'rails', '~> 5.2.0'
|
11
|
+
gem 'sqlite3', '< 1.4.0', :platform => [:ruby, :mswin, :mingw]
|
12
|
+
|
13
|
+
gem 'rspec-core', '~> 3.8.0'
|
14
|
+
gem 'rspec-rails', '~> 3.8.0'
|
15
|
+
gem 'rspec-support', '~> 3.8.0'
|
16
|
+
gem 'rspec-expectations', '~> 3.8.0'
|
17
|
+
gem 'rspec-mocks', '~> 3.8.0'
|
18
|
+
|
19
|
+
gem 'rake'
|
20
|
+
|
21
|
+
unless is_jruby
|
22
|
+
if RUBY_VERSION >= '2.5'
|
23
|
+
gem 'oj'
|
24
|
+
elsif RUBY_VERSION >= '2.4.0'
|
25
|
+
gem 'oj', '~> 2.16.1'
|
26
|
+
else
|
27
|
+
gem 'oj', '~> 2.12.14'
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
gem 'sidekiq', '>= 2.13.0'
|
32
|
+
|
33
|
+
platforms :rbx do
|
34
|
+
gem 'minitest'
|
35
|
+
gem 'racc'
|
36
|
+
gem 'rubinius-developer_tools'
|
37
|
+
gem 'rubysl', '~> 2.0' unless RUBY_VERSION.start_with?('1')
|
38
|
+
end
|
39
|
+
|
40
|
+
gem 'sucker_punch', '~> 2.0'
|
41
|
+
|
42
|
+
# We need last sinatra that uses rack 2.x
|
43
|
+
gem 'sinatra', :git => 'https://github.com/sinatra/sinatra'
|
44
|
+
|
45
|
+
gem 'database_cleaner'
|
46
|
+
gem 'codacy-coverage'
|
47
|
+
gem 'delayed_job', :require => false
|
48
|
+
gem 'generator_spec'
|
49
|
+
gem 'girl_friday', '>= 0.11.1'
|
50
|
+
gem 'rspec-command'
|
51
|
+
gem 'redis'
|
52
|
+
gem 'resque'
|
53
|
+
gem 'simplecov'
|
54
|
+
|
55
|
+
gem 'mime-types'
|
56
|
+
|
57
|
+
gem 'webmock', :require => false
|
58
|
+
|
59
|
+
gem 'aws-sdk-sqs'
|
60
|
+
gem 'shoryuken'
|
61
|
+
|
62
|
+
gemspec :path => '../'
|
@@ -11,7 +11,7 @@ gem 'jruby-openssl', :platform => :jruby
|
|
11
11
|
gem 'rails', '3.0.20'
|
12
12
|
gem 'rake', '< 11'
|
13
13
|
gem 'rspec-rails', '>= 2.14.0'
|
14
|
-
gem 'sqlite3', :platform => [:ruby, :mswin, :mingw]
|
14
|
+
gem 'sqlite3', '< 1.4.0', :platform => [:ruby, :mswin, :mingw]
|
15
15
|
|
16
16
|
gem 'oj', '~> 2.12.14' unless is_jruby
|
17
17
|
if RUBY_VERSION > '1.8.7' && RUBY_VERSION < '2.2.2'
|
@@ -37,7 +37,7 @@ gem 'delayed_job', '4.1.3', :require => false
|
|
37
37
|
gem 'genspec', '= 0.2.8'
|
38
38
|
gem 'girl_friday', '>= 0.11.1'
|
39
39
|
gem 'redis', '< 3.3.5'
|
40
|
-
gem 'resque'
|
40
|
+
gem 'resque', '< 2.0.0'
|
41
41
|
gem 'sinatra'
|
42
42
|
|
43
43
|
ruby_version = RUBY_VERSION.dup
|
data/lib/rails/rollbar_runner.rb
CHANGED
@@ -1,7 +1,10 @@
|
|
1
1
|
require 'rails'
|
2
2
|
require 'rollbar'
|
3
3
|
|
4
|
-
|
4
|
+
# Rails.root is not present here.
|
5
|
+
# RSpec needs ENV['DUMMYAPP_PATH'] in order to have a valid path.
|
6
|
+
# Dir.pwd is used in normal operation.
|
7
|
+
APP_PATH = File.expand_path('config/application', (ENV['DUMMYAPP_PATH'] || Dir.pwd))
|
5
8
|
|
6
9
|
module Rails
|
7
10
|
class RollbarRunner
|
@@ -36,6 +39,14 @@ module Rails
|
|
36
39
|
end
|
37
40
|
|
38
41
|
def eval_runner
|
42
|
+
if Rails.version >= '5.0.0'
|
43
|
+
rails5_runner
|
44
|
+
else
|
45
|
+
legacy_runner
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def legacy_runner
|
39
50
|
string_to_eval = File.read(runner_path)
|
40
51
|
|
41
52
|
::Rails.module_eval(<<-EOL, __FILE__, __LINE__ + 2)
|
@@ -43,6 +54,10 @@ module Rails
|
|
43
54
|
EOL
|
44
55
|
end
|
45
56
|
|
57
|
+
def rails5_runner
|
58
|
+
Rails::Command.invoke 'runner', ARGV
|
59
|
+
end
|
60
|
+
|
46
61
|
def rollbar_managed
|
47
62
|
yield
|
48
63
|
rescue => e
|
data/lib/rollbar/capistrano.rb
CHANGED
@@ -1,43 +1,77 @@
|
|
1
|
+
# This is a tasks file to use with Capistrano 2
|
2
|
+
|
1
3
|
require 'capistrano'
|
4
|
+
require 'rollbar/deploy'
|
5
|
+
require 'net/http'
|
6
|
+
require 'rubygems'
|
7
|
+
require 'json'
|
8
|
+
require 'rollbar/capistrano_tasks'
|
2
9
|
|
3
10
|
module Rollbar
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
Net::HTTP.start(uri.host, uri.port, :use_ssl => true) do |http|
|
36
|
-
http.request(request)
|
37
|
-
end
|
38
|
-
end
|
11
|
+
# Module for loading Rollbar Capistrano tasks into Capistrano 2
|
12
|
+
module Capistrano2
|
13
|
+
class << self
|
14
|
+
def load_into(configuration)
|
15
|
+
load_tasks(configuration)
|
16
|
+
load_tasks_flow(configuration)
|
17
|
+
load_properties(configuration)
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def load_tasks_flow(configuration)
|
23
|
+
configuration.load do
|
24
|
+
before 'deploy', 'rollbar:deploy_started'
|
25
|
+
|
26
|
+
after 'deploy', 'rollbar:deploy_succeeded'
|
27
|
+
after 'deploy:migrations', 'rollbar:deploy_succeeded'
|
28
|
+
after 'deploy:cold', 'rollbar:deploy_succeeded'
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def load_properties(configuration)
|
33
|
+
configuration.load do
|
34
|
+
_cset(:rollbar_role) { :app }
|
35
|
+
_cset(:rollbar_user) { ENV['USER'] || ENV['USERNAME'] }
|
36
|
+
_cset(:rollbar_env) { fetch(:rails_env, 'production') }
|
37
|
+
_cset(:rollbar_token) { abort("Please specify the Rollbar access token, set :rollbar_token, 'your token'") }
|
38
|
+
_cset(:rollbar_revision) { current_revision }
|
39
|
+
_cset(:rollbar_comment) { nil }
|
40
|
+
end
|
41
|
+
end
|
39
42
|
|
40
|
-
|
43
|
+
def load_tasks(configuration)
|
44
|
+
load_deploy_started(configuration)
|
45
|
+
load_deploy_succeeded(configuration)
|
46
|
+
end
|
47
|
+
|
48
|
+
def load_deploy_started(configuration)
|
49
|
+
load_task(
|
50
|
+
:desc => 'Send deployment started notification to Rollbar.',
|
51
|
+
:task => :deploy_started,
|
52
|
+
:configuration => configuration
|
53
|
+
) do
|
54
|
+
::Rollbar::CapistranoTasks.deploy_started(configuration, configuration.logger, configuration.dry_run)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def load_deploy_succeeded(configuration)
|
59
|
+
load_task(
|
60
|
+
:desc => 'Send deployment succeeded notification to Rollbar.',
|
61
|
+
:task => :deploy_succeeded,
|
62
|
+
:configuration => configuration
|
63
|
+
) do
|
64
|
+
::Rollbar::CapistranoTasks.deploy_succeeded(configuration, configuration.logger, configuration.dry_run)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def load_task(configuration:, desc:, task:)
|
69
|
+
configuration.load do
|
70
|
+
namespace :rollbar do
|
71
|
+
desc(desc)
|
72
|
+
task(task) do
|
73
|
+
yield
|
74
|
+
end
|
41
75
|
end
|
42
76
|
end
|
43
77
|
end
|
@@ -45,6 +79,4 @@ module Rollbar
|
|
45
79
|
end
|
46
80
|
end
|
47
81
|
|
48
|
-
if Capistrano::Configuration.instance
|
49
|
-
Rollbar::Capistrano.load_into(Capistrano::Configuration.instance)
|
50
|
-
end
|
82
|
+
Rollbar::Capistrano2.load_into(Capistrano::Configuration.instance) if Capistrano::Configuration.instance
|
data/lib/rollbar/capistrano3.rb
CHANGED
@@ -1 +1,53 @@
|
|
1
|
-
|
1
|
+
# This is a tasks file to use with Capistrano 3
|
2
|
+
|
3
|
+
require 'net/http'
|
4
|
+
require 'rubygems'
|
5
|
+
require 'json'
|
6
|
+
require 'rollbar/deploy'
|
7
|
+
require 'rollbar/capistrano_tasks'
|
8
|
+
|
9
|
+
namespace :rollbar do
|
10
|
+
desc 'Send deployment started notification to Rollbar.'
|
11
|
+
task :deploy_started do
|
12
|
+
on primary fetch(:rollbar_role) do
|
13
|
+
::Rollbar::CapistranoTasks.deploy_started(self, self, dry_run?)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
desc 'Send deployment succeeded notification to Rollbar.'
|
18
|
+
task :deploy_succeeded do
|
19
|
+
on primary fetch(:rollbar_role) do
|
20
|
+
::Rollbar::CapistranoTasks.deploy_succeeded(self, self, dry_run?)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
desc 'Send deployment failed notification to Rollbar.'
|
25
|
+
task :deploy_failed do
|
26
|
+
on primary fetch(:rollbar_role) do
|
27
|
+
::Rollbar::CapistranoTasks.deploy_failed(self, self, dry_run?)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
task :fail do
|
32
|
+
raise StandardError
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
namespace :deploy do
|
37
|
+
after 'deploy:set_current_revision', 'rollbar:deploy_started'
|
38
|
+
after 'deploy:finished', 'rollbar:deploy_succeeded'
|
39
|
+
after 'deploy:failed', 'rollbar:deploy_failed'
|
40
|
+
|
41
|
+
# Used for testing :deploy_failed task
|
42
|
+
# after 'rollbar:deploy_started', 'rollbar:fail'
|
43
|
+
end
|
44
|
+
|
45
|
+
namespace :load do
|
46
|
+
task :defaults do
|
47
|
+
set :rollbar_user, (proc { fetch :local_user, ENV['USER'] || ENV['USERNAME'] })
|
48
|
+
set :rollbar_env, (proc { fetch :rails_env, 'production' })
|
49
|
+
set :rollbar_token, (proc { abort "Please specify the Rollbar access token, set :rollbar_token, 'your token'" })
|
50
|
+
set :rollbar_role, (proc { :app })
|
51
|
+
set :rollbar_revision, (proc { fetch :current_revision })
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,131 @@
|
|
1
|
+
require 'capistrano'
|
2
|
+
require 'capistrano/version'
|
3
|
+
require 'rollbar/deploy'
|
4
|
+
|
5
|
+
module Rollbar
|
6
|
+
# Module containing the logic of Capistrano tasks for deploy tracking
|
7
|
+
module CapistranoTasks
|
8
|
+
class << self
|
9
|
+
def deploy_started(capistrano, logger, dry_run)
|
10
|
+
deploy_task(logger, :desc => 'Notifying Rollbar of deployment start') do
|
11
|
+
result = report_deploy_started(capistrano, dry_run)
|
12
|
+
|
13
|
+
info_request_response(logger, result)
|
14
|
+
|
15
|
+
capistrano.set(:rollbar_deploy_id, 123) if dry_run
|
16
|
+
|
17
|
+
skip_in_dry_run(logger, dry_run) do
|
18
|
+
if (deploy_id = result[:data][:deploy_id])
|
19
|
+
capistrano.set :rollbar_deploy_id, deploy_id
|
20
|
+
else
|
21
|
+
logger.error 'Unable to report deploy to Rollbar'
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def deploy_succeeded(capistrano, logger, dry_run)
|
28
|
+
deploy_update(capistrano, logger, dry_run, :desc => 'Setting deployment status to `succeeded` in Rollbar') do
|
29
|
+
report_deploy_succeeded(capistrano, dry_run)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def deploy_failed(capistrano, logger, dry_run)
|
34
|
+
deploy_update(capistrano, logger, dry_run, :desc => 'Setting deployment status to `failed` in Rollbar') do
|
35
|
+
report_deploy_failed(capistrano, dry_run)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
def deploy_task(logger, opts = {})
|
42
|
+
capistrano_300_warning(logger)
|
43
|
+
logger.info opts[:desc] if opts[:desc]
|
44
|
+
yield
|
45
|
+
end
|
46
|
+
|
47
|
+
def deploy_update(capistrano, logger, dry_run, opts = {})
|
48
|
+
deploy_task(logger, opts) do
|
49
|
+
depend_on_deploy_id(capistrano, logger) do
|
50
|
+
result = yield
|
51
|
+
|
52
|
+
info_request_response(logger, result)
|
53
|
+
|
54
|
+
skip_in_dry_run(logger, dry_run) do
|
55
|
+
if result[:response].is_a?(Net::HTTPSuccess)
|
56
|
+
logger.info 'Updated deploy status in Rollbar'
|
57
|
+
else
|
58
|
+
logger.error 'Unable to update deploy status in Rollbar'
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def capistrano_300_warning(logger)
|
66
|
+
logger.warn("You need to upgrade capistrano to '>= 3.1' version in order to correctly report deploys to Rollbar. (On 3.0, the reported revision will be incorrect.)") if ::Capistrano::VERSION =~ /^3\.0/
|
67
|
+
end
|
68
|
+
|
69
|
+
def report_deploy_started(capistrano, dry_run)
|
70
|
+
::Rollbar::Deploy.report(
|
71
|
+
{
|
72
|
+
:rollbar_username => capistrano.fetch(:rollbar_user),
|
73
|
+
:local_username => capistrano.fetch(:rollbar_user),
|
74
|
+
:comment => capistrano.fetch(:rollbar_comment),
|
75
|
+
:status => :started,
|
76
|
+
:proxy => :ENV,
|
77
|
+
:dry_run => dry_run
|
78
|
+
},
|
79
|
+
:access_token => capistrano.fetch(:rollbar_token),
|
80
|
+
:environment => capistrano.fetch(:rollbar_env),
|
81
|
+
:revision => capistrano.fetch(:rollbar_revision)
|
82
|
+
)
|
83
|
+
end
|
84
|
+
|
85
|
+
def report_deploy_succeeded(capistrano, dry_run)
|
86
|
+
::Rollbar::Deploy.update(
|
87
|
+
{
|
88
|
+
:proxy => :ENV,
|
89
|
+
:dry_run => dry_run
|
90
|
+
},
|
91
|
+
:access_token => capistrano.fetch(:rollbar_token),
|
92
|
+
:deploy_id => capistrano.fetch(:rollbar_deploy_id),
|
93
|
+
:status => :succeeded
|
94
|
+
)
|
95
|
+
end
|
96
|
+
|
97
|
+
def report_deploy_failed(capistrano, dry_run)
|
98
|
+
::Rollbar::Deploy.update(
|
99
|
+
{
|
100
|
+
:proxy => :ENV,
|
101
|
+
:dry_run => dry_run
|
102
|
+
},
|
103
|
+
:access_token => capistrano.fetch(:rollbar_token),
|
104
|
+
:deploy_id => capistrano.fetch(:rollbar_deploy_id),
|
105
|
+
:status => :failed
|
106
|
+
)
|
107
|
+
end
|
108
|
+
|
109
|
+
def depend_on_deploy_id(capistrano, logger)
|
110
|
+
if capistrano.fetch(:rollbar_deploy_id)
|
111
|
+
yield
|
112
|
+
else
|
113
|
+
logger.error 'Failed to update the deploy in Rollbar. No deploy id available.'
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
def skip_in_dry_run(logger, dry_run)
|
118
|
+
if dry_run
|
119
|
+
logger.info 'Skipping sending HTTP requests to Rollbar in dry run.'
|
120
|
+
else
|
121
|
+
yield
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
def info_request_response(logger, result)
|
126
|
+
logger.info result[:request_info]
|
127
|
+
logger.info result[:response_info] if result[:response_info]
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
@@ -107,7 +107,7 @@ module Rollbar
|
|
107
107
|
@js_options = {}
|
108
108
|
@scrub_fields = [:passwd, :password, :password_confirmation, :secret,
|
109
109
|
:confirm_password, :password_confirmation, :secret_token,
|
110
|
-
:api_key, :access_token]
|
110
|
+
:api_key, :access_token, :session_id]
|
111
111
|
@scrub_user = true
|
112
112
|
@scrub_password = true
|
113
113
|
@randomize_scrub_length = true
|
@@ -130,7 +130,7 @@ module Rollbar
|
|
130
130
|
@anonymize_user_ip = false
|
131
131
|
@hooks = {
|
132
132
|
:on_error_response => nil, # params: response
|
133
|
-
:on_report_internal_error => nil, #params: exception
|
133
|
+
:on_report_internal_error => nil, # params: exception
|
134
134
|
}
|
135
135
|
end
|
136
136
|
|
@@ -161,6 +161,15 @@ module Rollbar
|
|
161
161
|
self
|
162
162
|
end
|
163
163
|
|
164
|
+
def use_active_job(options = {})
|
165
|
+
require 'rollbar/delay/active_job'
|
166
|
+
|
167
|
+
Rollbar::Delay::ActiveJob.queue_as(options[:queue] || Rollbar::Delay::ActiveJob.default_queue_name)
|
168
|
+
|
169
|
+
@use_async = true
|
170
|
+
@async_handler = Rollbar::Delay::ActiveJob
|
171
|
+
end
|
172
|
+
|
164
173
|
def use_delayed_job(options = {})
|
165
174
|
require 'rollbar/delay/delayed_job'
|
166
175
|
|
@@ -263,7 +272,7 @@ module Rollbar
|
|
263
272
|
def logger
|
264
273
|
@logger ||= default_logger.call
|
265
274
|
end
|
266
|
-
|
275
|
+
|
267
276
|
def hook(symbol, &block)
|
268
277
|
if @hooks.has_key?(symbol)
|
269
278
|
if block_given?
|
@@ -275,7 +284,7 @@ module Rollbar
|
|
275
284
|
raise StandardError.new "Hook :" + symbol.to_s + " is not supported by Rollbar SDK."
|
276
285
|
end
|
277
286
|
end
|
278
|
-
|
287
|
+
|
279
288
|
def execute_hook(symbol, *args)
|
280
289
|
hook(symbol).call(*args) if hook(symbol).is_a?(Proc)
|
281
290
|
end
|