airbrake 10.0.0 → 13.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/lib/airbrake/capistrano/capistrano2.rb +3 -1
  3. data/lib/airbrake/capistrano/capistrano3.rb +3 -1
  4. data/lib/airbrake/capistrano.rb +2 -0
  5. data/lib/airbrake/delayed_job.rb +30 -30
  6. data/lib/airbrake/logger.rb +5 -1
  7. data/lib/airbrake/rack/context_filter.rb +12 -6
  8. data/lib/airbrake/rack/http_headers_filter.rb +6 -4
  9. data/lib/airbrake/rack/http_params_filter.rb +2 -0
  10. data/lib/airbrake/rack/instrumentable.rb +116 -4
  11. data/lib/airbrake/rack/middleware.rb +2 -0
  12. data/lib/airbrake/rack/request_body_filter.rb +2 -0
  13. data/lib/airbrake/rack/request_store.rb +2 -0
  14. data/lib/airbrake/rack/route_filter.rb +5 -1
  15. data/lib/airbrake/rack/session_filter.rb +2 -0
  16. data/lib/airbrake/rack/user.rb +4 -0
  17. data/lib/airbrake/rack/user_filter.rb +2 -0
  18. data/lib/airbrake/rack.rb +4 -0
  19. data/lib/airbrake/rails/action_cable/notify_callback.rb +2 -0
  20. data/lib/airbrake/rails/action_cable.rb +21 -17
  21. data/lib/airbrake/rails/action_controller.rb +5 -0
  22. data/lib/airbrake/rails/action_controller_notify_subscriber.rb +4 -0
  23. data/lib/airbrake/rails/action_controller_performance_breakdown_subscriber.rb +4 -0
  24. data/lib/airbrake/rails/action_controller_route_subscriber.rb +4 -0
  25. data/lib/airbrake/rails/active_job.rb +4 -10
  26. data/lib/airbrake/rails/active_record.rb +2 -0
  27. data/lib/airbrake/rails/active_record_subscriber.rb +4 -0
  28. data/lib/airbrake/rails/app.rb +24 -0
  29. data/lib/airbrake/rails/backtrace_cleaner.rb +13 -0
  30. data/lib/airbrake/rails/curb.rb +19 -22
  31. data/lib/airbrake/rails/event.rb +16 -2
  32. data/lib/airbrake/rails/excon_subscriber.rb +4 -0
  33. data/lib/airbrake/rails/http.rb +13 -7
  34. data/lib/airbrake/rails/http_client.rb +12 -6
  35. data/lib/airbrake/rails/net_http.rb +14 -6
  36. data/lib/airbrake/rails/railtie.rb +8 -98
  37. data/lib/airbrake/rails/railties/action_controller_tie.rb +90 -0
  38. data/lib/airbrake/rails/railties/active_record_tie.rb +74 -0
  39. data/lib/airbrake/rails/railties/middleware_tie.rb +62 -0
  40. data/lib/airbrake/rails/typhoeus.rb +11 -7
  41. data/lib/airbrake/rails.rb +8 -8
  42. data/lib/airbrake/rake/tasks.rb +15 -13
  43. data/lib/airbrake/rake.rb +49 -46
  44. data/lib/airbrake/resque.rb +28 -25
  45. data/lib/airbrake/shoryuken.rb +4 -4
  46. data/lib/airbrake/sidekiq/retryable_jobs_filter.rb +2 -0
  47. data/lib/airbrake/sidekiq.rb +7 -6
  48. data/lib/airbrake/sneakers.rb +34 -28
  49. data/lib/airbrake/version.rb +3 -1
  50. data/lib/airbrake.rb +2 -0
  51. data/lib/generators/airbrake_generator.rb +5 -6
  52. data/lib/generators/airbrake_initializer.rb.erb +67 -65
  53. metadata +52 -139
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'airbrake-ruby'
2
4
 
3
5
  namespace :airbrake do
@@ -51,11 +53,11 @@ namespace :airbrake do
51
53
  raise Airbrake::Error, 'airbrake-ruby is not configured' unless Airbrake.configured?
52
54
 
53
55
  deploy_params = {
54
- environment: ENV['ENVIRONMENT'],
55
- username: ENV['USERNAME'],
56
- revision: ENV['REVISION'],
57
- repository: ENV['REPOSITORY'],
58
- version: ENV['VERSION'],
56
+ environment: ENV.fetch('ENVIRONMENT', nil),
57
+ username: ENV.fetch('USERNAME', nil),
58
+ revision: ENV.fetch('REVISION', nil),
59
+ repository: ENV.fetch('REPOSITORY', nil),
60
+ version: ENV.fetch('VERSION', nil),
59
61
  }
60
62
  promise = Airbrake.notify_deploy(deploy_params)
61
63
  promise.then do
@@ -66,10 +68,10 @@ namespace :airbrake do
66
68
 
67
69
  desc 'Install a Heroku deploy hook to notify Airbrake of deploys'
68
70
  task :install_heroku_deploy_hook do
69
- app = ENV['HEROKU_APP']
71
+ app = ENV.fetch('HEROKU_APP', nil)
70
72
 
71
73
  config = Bundler.with_clean_env do
72
- `heroku config --shell#{ " --app #{app}" if app }`
74
+ `heroku config --shell#{" --app #{app}" if app}`
73
75
  end
74
76
 
75
77
  heroku_env = config.each_line.with_object({}) do |line, h|
@@ -83,11 +85,11 @@ namespace :airbrake do
83
85
 
84
86
  unless (env = heroku_env['RAILS_ENV'])
85
87
  env = 'production'
86
- puts "Airbrake couldn't identify your app's environment, so the '#{env}'" \
87
- " environment will be used."
88
+ puts "Airbrake couldn't identify your app's environment, " \
89
+ "so the '#{env}' environment will be used."
88
90
  end
89
91
 
90
- unless (repo = ENV['REPOSITORY_URL'])
92
+ unless (repo = ENV.fetch('REPOSITORY_URL', nil))
91
93
  repo = `git remote get-url origin 2>/dev/null`.chomp
92
94
  if repo.empty?
93
95
  puts "Airbrake couldn't identify your app's repository."
@@ -97,14 +99,14 @@ namespace :airbrake do
97
99
  end
98
100
  end
99
101
 
100
- url = "https://airbrake.io/api/v3/projects/#{id}/heroku-deploys?key=#{key}"
102
+ url = ["https://airbrake.io/api/v3/projects/#{id}/heroku-deploys?key=#{key}"]
101
103
  url << "&environment=#{env}"
102
104
  url << "&repository=#{repo}" unless repo.empty?
103
105
 
104
- command = %(heroku addons:create deployhooks:http --url="#{url}")
106
+ command = [%(heroku addons:create deployhooks:http --url="#{url.join}")]
105
107
  command << " --app #{app}" if app
106
108
 
107
- puts "$ #{command}"
109
+ puts "$ #{command.join}"
108
110
  Bundler.with_clean_env { puts `#{command}` }
109
111
  end
110
112
  end
data/lib/airbrake/rake.rb CHANGED
@@ -1,63 +1,66 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # This is not bulletproof, but if this file is executed before a task
2
4
  # definition, we can grab tasks descriptions and locations.
3
5
  # See: https://goo.gl/ksn6PE
4
6
  Rake::TaskManager.record_task_metadata = true
5
7
 
6
- module Rake
7
- # Redefine +Rake::Task#execute+, so it can report errors to Airbrake.
8
- class Task
9
- # Store the original method to use it later.
10
- alias execute_without_airbrake execute
11
-
12
- # A wrapper around the original +#execute+, that catches all errors and
13
- # notifies Airbrake.
14
- #
15
- # rubocop:disable Lint/RescueException
16
- def execute(args = nil)
17
- execute_without_airbrake(args)
18
- rescue Exception => ex
19
- notify_airbrake(ex, args)
20
- raise ex
21
- end
22
- # rubocop:enable Lint/RescueException
8
+ module Airbrake
9
+ module Rake
10
+ # Redefine +Rake::Task#execute+, so it can report errors to Airbrake.
11
+ module Task
12
+ # A wrapper around the original +#execute+, that catches all errors and
13
+ # notifies Airbrake.
14
+ #
15
+ # rubocop:disable Lint/RescueException
16
+ def execute(args = nil)
17
+ super(args)
18
+ rescue Exception => ex
19
+ notify_airbrake(ex, args)
20
+ raise ex
21
+ end
22
+ # rubocop:enable Lint/RescueException
23
23
 
24
- private
24
+ private
25
25
 
26
- def notify_airbrake(exception, args)
27
- notice = Airbrake.build_notice(exception)
28
- notice[:context][:component] = 'rake'
29
- notice[:context][:action] = name
30
- notice[:params].merge!(
31
- rake_task: task_info,
32
- execute_args: args,
33
- argv: ARGV.join(' '),
34
- )
26
+ def notify_airbrake(exception, args)
27
+ notice = Airbrake.build_notice(exception)
28
+ notice[:context][:component] = 'rake'
29
+ notice[:context][:action] = name
30
+ notice[:params].merge!(
31
+ rake_task: task_info,
32
+ execute_args: args,
33
+ argv: ARGV.join(' '),
34
+ )
35
35
 
36
- Airbrake.notify_sync(notice)
37
- end
36
+ Airbrake.notify_sync(notice)
37
+ end
38
38
 
39
- # rubocop:disable Metrics/CyclomaticComplexity, Metrics/AbcSize
40
- def task_info
41
- info = {}
39
+ # rubocop:disable Metrics/CyclomaticComplexity, Metrics/AbcSize
40
+ def task_info
41
+ info = {}
42
42
 
43
- info[:name] = name
44
- info[:timestamp] = timestamp.to_s
45
- info[:investigation] = investigation
43
+ info[:name] = name
44
+ info[:timestamp] = timestamp.to_s
45
+ info[:investigation] = investigation
46
46
 
47
- info[:full_comment] = full_comment if full_comment
48
- info[:arg_names] = arg_names if arg_names.any?
49
- info[:arg_description] = arg_description if arg_description
50
- info[:locations] = locations if locations.any?
51
- info[:sources] = sources if sources.any?
47
+ info[:full_comment] = full_comment if full_comment
48
+ info[:arg_names] = arg_names if arg_names.any?
49
+ info[:arg_description] = arg_description if arg_description
50
+ info[:locations] = locations if locations.any?
51
+ info[:sources] = sources if sources.any?
52
52
 
53
- if prerequisite_tasks.any?
54
- info[:prerequisite_tasks] = prerequisite_tasks.map do |p|
55
- p.__send__(:task_info)
53
+ if prerequisite_tasks.any?
54
+ info[:prerequisite_tasks] = prerequisite_tasks.map do |p|
55
+ p.__send__(:task_info)
56
+ end
56
57
  end
57
- end
58
58
 
59
- info
59
+ info
60
+ end
61
+ # rubocop:enable Metrics/CyclomaticComplexity, Metrics/AbcSize
60
62
  end
61
- # rubocop:enable Metrics/CyclomaticComplexity, Metrics/AbcSize
62
63
  end
63
64
  end
65
+
66
+ Rake::Task.prepend(Airbrake::Rake::Task)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Resque
2
4
  module Failure
3
5
  # Provides Resque integration with Airbrake.
@@ -28,32 +30,33 @@ module Resque
28
30
  end
29
31
  end
30
32
 
31
- module Resque
32
- # Measures elapsed time of a job and notifies Airbrake of the execution
33
- # status.
34
- #
35
- # @since v9.6.0
36
- class Job
37
- # Store the original method to use it later.
38
- alias perform_without_airbrake perform
39
-
40
- def perform
41
- timing = Airbrake::Benchmark.measure do
42
- perform_without_airbrake
33
+ module Airbrake
34
+ module Resque
35
+ # Measures elapsed time of a job and notifies Airbrake of the execution
36
+ # status.
37
+ #
38
+ # @since v9.6.0
39
+ module Job
40
+ def perform
41
+ timing = Airbrake::Benchmark.measure do
42
+ super
43
+ end
44
+ rescue StandardError => exception
45
+ Airbrake.notify_queue_sync(
46
+ queue: payload['class'],
47
+ error_count: 1,
48
+ timing: 0.01,
49
+ )
50
+ raise exception
51
+ else
52
+ Airbrake.notify_queue_sync(
53
+ queue: payload['class'],
54
+ error_count: 0,
55
+ timing: timing,
56
+ )
43
57
  end
44
- rescue StandardError => exception
45
- Airbrake.notify_queue_sync(
46
- queue: payload['class'],
47
- error_count: 1,
48
- timing: 0.01,
49
- )
50
- raise exception
51
- else
52
- Airbrake.notify_queue_sync(
53
- queue: payload['class'],
54
- error_count: 0,
55
- timing: timing,
56
- )
57
58
  end
58
59
  end
59
60
  end
61
+
62
+ Resque::Job.prepend(Airbrake::Resque::Job)
@@ -1,12 +1,12 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Airbrake
2
4
  module Shoryuken
3
5
  # Provides integration with Shoryuken.
4
6
  class ErrorHandler
5
7
  # rubocop:disable Lint/RescueException
6
- def call(worker, queue, _sqs_msg, body)
7
- timing = Airbrake::Benchmark.measure do
8
- yield
9
- end
8
+ def call(worker, queue, _sqs_msg, body, &block)
9
+ timing = Airbrake::Benchmark.measure(&block)
10
10
  rescue Exception => exception
11
11
  notify_airbrake(exception, worker, queue, body)
12
12
  Airbrake.notify_queue(
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Airbrake
2
4
  module Sidekiq
3
5
  # Filter that can ignore notices from jobs that failed but will be retried
@@ -1,13 +1,13 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'airbrake/sidekiq/retryable_jobs_filter'
2
4
 
3
5
  module Airbrake
4
6
  module Sidekiq
5
7
  # Provides integration with Sidekiq v2+.
6
8
  class ErrorHandler
7
- def call(_worker, context, _queue)
8
- timing = Airbrake::Benchmark.measure do
9
- yield
10
- end
9
+ def call(_worker, context, _queue, &block)
10
+ timing = Airbrake::Benchmark.measure(&block)
11
11
  rescue Exception => exception # rubocop:disable Lint/RescueException
12
12
  notify_airbrake(exception, context)
13
13
  Airbrake.notify_queue(
@@ -27,7 +27,7 @@ module Airbrake
27
27
  private
28
28
 
29
29
  def notify_airbrake(exception, context)
30
- Airbrake.notify(exception, context) do |notice|
30
+ Airbrake.notify(exception, job: context) do |notice|
31
31
  notice[:context][:component] = 'sidekiq'
32
32
  notice[:context][:action] = action(context)
33
33
  end
@@ -36,9 +36,10 @@ module Airbrake
36
36
  # @return [String] job's name. When ActiveJob is present, retrieve
37
37
  # job_class. When used directly, use worker's name
38
38
  def action(context)
39
- klass = context['class'] || context[:job] && context[:job]['class']
39
+ klass = context['class'] || (context[:job] && context[:job]['class'])
40
40
  return klass unless context[:job] && context[:job]['args'].first.is_a?(Hash)
41
41
  return klass unless (job_class = context[:job]['args'].first['job_class'])
42
+
42
43
  job_class
43
44
  end
44
45
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Airbrake
2
4
  module Sneakers
3
5
  # Provides integration with Sneakers.
@@ -10,17 +12,21 @@ module Airbrake
10
12
  # @see https://github.com/airbrake/airbrake/issues/850
11
13
  IGNORED_KEYS = %i[delivery_tag consumer channel].freeze
12
14
 
13
- def call(exception, worker = nil, **context)
15
+ # rubocop:disable Style/OptionalArguments
16
+ def call(exception, worker = nil, context)
17
+ # Later versions add a middle argument.
14
18
  Airbrake.notify(exception, filter_context(context)) do |notice|
15
19
  notice[:context][:component] = 'sneakers'
16
20
  notice[:context][:action] = worker.class.to_s
17
21
  end
18
22
  end
23
+ # rubocop:enable Style/OptionalArguments
19
24
 
20
25
  private
21
26
 
22
27
  def filter_context(context)
23
28
  return context unless context[:delivery_info]
29
+
24
30
  h = context.dup
25
31
  h[:delivery_info] = context[:delivery_info].reject do |k, _v|
26
32
  IGNORED_KEYS.include?(k)
@@ -33,34 +39,34 @@ end
33
39
 
34
40
  Sneakers.error_reporters << Airbrake::Sneakers::ErrorReporter.new
35
41
 
36
- module Sneakers
37
- # @todo Migrate to Sneakers v2.12.0 middleware API when it's released
38
- # @see https://github.com/jondot/sneakers/pull/364
39
- module Worker
40
- # Sneakers v2.7.0+ renamed `do_work` to `process_work`.
41
- if method_defined?(:process_work)
42
- alias process_work_without_airbrake process_work
43
- else
44
- alias process_work_without_airbrake do_work
45
- end
46
-
47
- def process_work(delivery_info, metadata, msg, handler)
48
- timing = Airbrake::Benchmark.measure do
49
- process_work_without_airbrake(delivery_info, metadata, msg, handler)
42
+ module Airbrake
43
+ module Sneakers
44
+ # @todo Migrate to Sneakers v2.12.0 middleware API when it's released
45
+ # @see https://github.com/jondot/sneakers/pull/364
46
+ module Worker
47
+ # Sneakers v2.7.0+ renamed `do_work` to `process_work`.
48
+ define_method(
49
+ ::Sneakers::Worker.method_defined?(:process_work) ? :process_work : :do_work,
50
+ ) do |delivery_info, metadata, msg, handler|
51
+ timing = Airbrake::Benchmark.measure do
52
+ super(delivery_info, metadata, msg, handler)
53
+ end
54
+ rescue Exception => exception # rubocop:disable Lint/RescueException
55
+ Airbrake.notify_queue(
56
+ queue: self.class.to_s,
57
+ error_count: 1,
58
+ timing: 0.01,
59
+ )
60
+ raise exception
61
+ else
62
+ Airbrake.notify_queue(
63
+ queue: self.class.to_s,
64
+ error_count: 0,
65
+ timing: timing,
66
+ )
50
67
  end
51
- rescue Exception => exception # rubocop:disable Lint/RescueException
52
- Airbrake.notify_queue(
53
- queue: self.class.to_s,
54
- error_count: 1,
55
- timing: 0.01,
56
- )
57
- raise exception
58
- else
59
- Airbrake.notify_queue(
60
- queue: self.class.to_s,
61
- error_count: 0,
62
- timing: timing,
63
- )
64
68
  end
65
69
  end
66
70
  end
71
+
72
+ Sneakers::Worker.prepend(Airbrake::Sneakers::Worker)
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # We use Semantic Versioning v2.0.0
2
4
  # More information: http://semver.org/
3
5
  module Airbrake
4
- AIRBRAKE_VERSION = '10.0.0'.freeze
6
+ AIRBRAKE_VERSION = '13.0.3'
5
7
  end
data/lib/airbrake.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'shellwords'
2
4
  require 'English'
3
5
 
@@ -1,22 +1,21 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Creates the Airbrake initializer file for Rails apps.
2
4
  #
3
5
  # @example Invokation from terminal
4
- # rails generate airbrake PROJECT_KEY PROJECT_ID [NAME]
6
+ # rails generate airbrake [NAME]
5
7
  #
6
8
  class AirbrakeGenerator < Rails::Generators::Base
7
9
  # Adds current directory to source paths, so we can find the template file.
8
10
  source_root File.expand_path(__dir__)
9
11
 
10
- argument :project_id, required: false
11
- argument :project_key, required: false
12
-
13
12
  # Makes the NAME option optional, which allows to subclass from Base, so we
14
13
  # can pass arguments to the ERB template.
15
14
  #
16
- # @see http://asciicasts.com/episodes/218-making-generators-in-rails-3
15
+ # @see https://asciicasts.com/episodes/218-making-generators-in-rails-3.html
17
16
  argument :name, type: :string, default: 'application'
18
17
 
19
- desc 'Configures the Airbrake notifier with your project id and project key'
18
+ desc 'Configures the Airbrake notifier'
20
19
  def generate_layout
21
20
  template 'airbrake_initializer.rb.erb', 'config/initializers/airbrake.rb'
22
21
  end
@@ -1,78 +1,80 @@
1
- # Airbrake is an online tool that provides robust exception tracking in your Rails
2
- # applications. In doing so, it allows you to easily review errors, tie an error
3
- # to an individual piece of code, and trace the cause back to recent
4
- # changes. Airbrake enables for easy categorization, searching, and prioritization
5
- # of exceptions so that when errors occur, your team can quickly determine the
6
- # root cause.
1
+ # frozen_string_literal: true
2
+
3
+ # Airbrake is an online tool that provides robust exception tracking in your
4
+ # Rails applications. In doing so, it allows you to easily review errors, tie an
5
+ # error to an individual piece of code, and trace the cause back to recent
6
+ # changes. Airbrake enables for easy categorization, searching, and
7
+ # prioritization of exceptions so that when errors occur, your team can quickly
8
+ # determine the root cause.
7
9
  #
8
10
  # Configuration details:
9
11
  # https://github.com/airbrake/airbrake-ruby#configuration
10
- Airbrake.configure do |c|
11
- # You must set both project_id & project_key. To find your project_id and
12
- # project_key navigate to your project's General Settings and copy the values
13
- # from the right sidebar.
14
- # https://github.com/airbrake/airbrake-ruby#project_id--project_key
15
- <% if project_id -%>
16
- c.project_id = <%= project_id %>
17
- <% else -%>
18
- c.project_id = ENV['AIRBRAKE_PROJECT_ID']
19
- <% end -%>
20
- <% if project_key -%>
21
- c.project_key = '<%= project_key %>'
22
- <% else -%>
23
- c.project_key = ENV['AIRBRAKE_API_KEY']
24
- <% end -%>
12
+ if (project_id = ENV['AIRBRAKE_PROJECT_ID']) &&
13
+ project_key = (ENV['AIRBRAKE_PROJECT_KEY'] || ENV['AIRBRAKE_API_KEY'])
14
+ Airbrake.configure do |c|
15
+ # You must set both project_id & project_key. To find your project_id and
16
+ # project_key navigate to your project's General Settings and copy the
17
+ # values from the right sidebar.
18
+ # https://github.com/airbrake/airbrake-ruby#project_id--project_key
19
+ c.project_id = project_id
20
+ c.project_key = project_key
25
21
 
26
- # Configures the root directory of your project. Expects a String or a
27
- # Pathname, which represents the path to your project. Providing this option
28
- # helps us to filter out repetitive data from backtrace frames and link to
29
- # GitHub files from our dashboard.
30
- # https://github.com/airbrake/airbrake-ruby#root_directory
31
- c.root_directory = Rails.root
22
+ # Configures the root directory of your project. Expects a String or a
23
+ # Pathname, which represents the path to your project. Providing this option
24
+ # helps us to filter out repetitive data from backtrace frames and link to
25
+ # GitHub files from our dashboard.
26
+ # https://github.com/airbrake/airbrake-ruby#root_directory
27
+ c.root_directory = Rails.root
32
28
 
33
- # By default, Airbrake Ruby outputs to STDOUT. In Rails apps it makes sense to
34
- # use the Rails' logger.
35
- # https://github.com/airbrake/airbrake-ruby#logger
36
- c.logger = Airbrake::Rails.logger
29
+ # By default, Airbrake Ruby outputs to STDOUT. In Rails apps it makes sense
30
+ # to use the Rails' logger.
31
+ # https://github.com/airbrake/airbrake-ruby#logger
32
+ c.logger = Airbrake::Rails.logger
37
33
 
38
- # Configures the environment the application is running in. Helps the Airbrake
39
- # dashboard to distinguish between exceptions occurring in different
40
- # environments.
41
- # NOTE: This option must be set in order to make the 'ignore_environments'
42
- # option work.
43
- # https://github.com/airbrake/airbrake-ruby#environment
44
- c.environment = Rails.env
34
+ # Configures the environment the application is running in. Helps the
35
+ # Airbrake dashboard to distinguish between exceptions occurring in
36
+ # different environments.
37
+ # NOTE: This option must be set in order to make the 'ignore_environments'
38
+ # option work.
39
+ # https://github.com/airbrake/airbrake-ruby#environment
40
+ c.environment = Rails.env
45
41
 
46
- # Setting this option allows Airbrake to filter exceptions occurring in
47
- # unwanted environments such as :test.
48
- # NOTE: This option *does not* work if you don't set the 'environment' option.
49
- # https://github.com/airbrake/airbrake-ruby#ignore_environments
50
- c.ignore_environments = %w[test]
42
+ # Setting this option allows Airbrake to filter exceptions occurring in
43
+ # unwanted environments such as :test. NOTE: This option *does not* work if
44
+ # you don't set the 'environment' option.
45
+ # https://github.com/airbrake/airbrake-ruby#ignore_environments
46
+ c.ignore_environments = %w[test]
51
47
 
52
- # A list of parameters that should be filtered out of what is sent to
53
- # Airbrake. By default, all "password" attributes will have their contents
54
- # replaced.
55
- # https://github.com/airbrake/airbrake-ruby#blacklist_keys
56
- c.blacklist_keys = [/password/i, /authorization/i]
48
+ # A list of parameters that should be filtered out of what is sent to
49
+ # Airbrake. By default, all "password" attributes will have their contents
50
+ # replaced.
51
+ # https://github.com/airbrake/airbrake-ruby#blocklist_keys
52
+ c.blocklist_keys = [/password/i, /authorization/i]
57
53
 
58
- # Alternatively, you can integrate with Rails' filter_parameters.
59
- # Read more: https://goo.gl/gqQ1xS
60
- # c.blacklist_keys = Rails.application.config.filter_parameters
61
- end
54
+ # Alternatively, you can integrate with Rails' filter_parameters.
55
+ # Read more: https://goo.gl/gqQ1xS
56
+ # c.blocklist_keys = Rails.application.config.filter_parameters
57
+ end
62
58
 
63
- # A filter that collects request body information. Enable it if you are sure you
64
- # don't send sensitive information to Airbrake in your body (such as passwords).
65
- # https://github.com/airbrake/airbrake#requestbodyfilter
66
- # Airbrake.add_filter(Airbrake::Rack::RequestBodyFilter.new)
59
+ # A filter that collects request body information. Enable it if you are sure you
60
+ # don't send sensitive information to Airbrake in your body (such as passwords).
61
+ # https://github.com/airbrake/airbrake#requestbodyfilter
62
+ # Airbrake.add_filter(Airbrake::Rack::RequestBodyFilter.new)
67
63
 
68
- # Attaches thread & fiber local variables along with general thread information.
69
- # Airbrake.add_filter(Airbrake::Filters::ThreadFilter.new)
64
+ # Attaches thread & fiber local variables along with general thread information.
65
+ # Airbrake.add_filter(Airbrake::Filters::ThreadFilter.new)
70
66
 
71
- # Attaches loaded dependencies to the notice object
72
- # (under context/versions/dependencies).
73
- # Airbrake.add_filter(Airbrake::Filters::DependencyFilter.new)
67
+ # Attaches loaded dependencies to the notice object
68
+ # (under context/versions/dependencies).
69
+ # Airbrake.add_filter(Airbrake::Filters::DependencyFilter.new)
74
70
 
75
- # If you want to convert your log messages to Airbrake errors, we offer an
76
- # integration with the Logger class from stdlib.
77
- # https://github.com/airbrake/airbrake#logger
78
- # Rails.logger = Airbrake::AirbrakeLogger.new(Rails.logger)
71
+ # If you want to convert your log messages to Airbrake errors, we offer an
72
+ # integration with the Logger class from stdlib.
73
+ # https://github.com/airbrake/airbrake#logger
74
+ # Rails.logger = Airbrake::AirbrakeLogger.new(Rails.logger)
75
+ else
76
+ Rails.logger.warn(
77
+ "#{__FILE__}: Airbrake project id or project key is not set. " \
78
+ "Skipping Airbrake configuration"
79
+ )
80
+ end