airbrake 4.3.8 → 5.0.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.
Files changed (134) hide show
  1. checksums.yaml +4 -4
  2. data/lib/airbrake/capistrano/tasks.rb +64 -0
  3. data/lib/airbrake/delayed_job/plugin.rb +48 -0
  4. data/lib/airbrake/rack/middleware.rb +45 -0
  5. data/lib/airbrake/rack/notice_builder.rb +80 -0
  6. data/lib/airbrake/rack/user.rb +51 -0
  7. data/lib/airbrake/rails/action_controller.rb +35 -0
  8. data/lib/airbrake/rails/active_job.rb +23 -0
  9. data/lib/airbrake/rails/active_record.rb +40 -0
  10. data/lib/airbrake/rails/railtie.rb +61 -0
  11. data/lib/airbrake/rake/task_ext.rb +61 -0
  12. data/lib/airbrake/rake/tasks.rb +93 -0
  13. data/lib/airbrake/resque/failure.rb +19 -0
  14. data/lib/airbrake/sidekiq/error_handler.rb +35 -0
  15. data/lib/airbrake/version.rb +4 -1
  16. data/lib/airbrake.rb +16 -185
  17. data/lib/generators/airbrake_generator.rb +25 -0
  18. data/lib/generators/airbrake_initializer.rb.erb +55 -0
  19. data/spec/airbrake_spec.rb +0 -0
  20. data/spec/apps/rack/dummy_app.rb +17 -0
  21. data/spec/apps/rails/dummy_app.rb +150 -0
  22. data/spec/apps/rails/dummy_task.rake +20 -0
  23. data/spec/apps/rails/logs/32.log +13358 -0
  24. data/spec/apps/rails/logs/40.log +6854 -0
  25. data/spec/apps/rails/logs/41.log +3170 -0
  26. data/spec/apps/rails/logs/42.log +23919 -0
  27. data/spec/apps/rails/logs/50.log +10976 -0
  28. data/spec/apps/sinatra/dummy_app.rb +12 -0
  29. data/spec/integration/rack/rack_spec.rb +17 -0
  30. data/spec/integration/rails/rails_spec.rb +135 -0
  31. data/spec/integration/rails/rake_spec.rb +160 -0
  32. data/spec/integration/shared_examples/rack_examples.rb +106 -0
  33. data/spec/integration/sinatra/sinatra_spec.rb +15 -0
  34. data/spec/spec_helper.rb +127 -0
  35. data/spec/unit/rack/middleware_spec.rb +80 -0
  36. data/spec/unit/rack/notice_builder_spec.rb +35 -0
  37. data/spec/unit/rack/user_spec.rb +78 -0
  38. data/spec/unit/rake/tasks_spec.rb +40 -0
  39. data/spec/unit/sidekiq/error_handler_spec.rb +29 -0
  40. metadata +108 -323
  41. data/CHANGELOG +0 -1716
  42. data/Gemfile +0 -3
  43. data/Guardfile +0 -6
  44. data/INSTALL +0 -20
  45. data/LICENSE +0 -61
  46. data/README.md +0 -148
  47. data/README_FOR_HEROKU_ADDON.md +0 -102
  48. data/Rakefile +0 -179
  49. data/TESTED_AGAINST +0 -7
  50. data/airbrake.gemspec +0 -41
  51. data/bin/airbrake +0 -12
  52. data/features/metal.feature +0 -34
  53. data/features/rack.feature +0 -60
  54. data/features/rails.feature +0 -324
  55. data/features/rake.feature +0 -33
  56. data/features/sinatra.feature +0 -126
  57. data/features/step_definitions/file_steps.rb +0 -14
  58. data/features/step_definitions/rack_steps.rb +0 -27
  59. data/features/step_definitions/rails_application_steps.rb +0 -267
  60. data/features/step_definitions/rake_steps.rb +0 -22
  61. data/features/support/airbrake_shim.rb.template +0 -11
  62. data/features/support/aruba.rb +0 -5
  63. data/features/support/env.rb +0 -39
  64. data/features/support/matchers.rb +0 -35
  65. data/features/support/rails.rb +0 -156
  66. data/features/support/rake/Rakefile +0 -77
  67. data/features/user_informer.feature +0 -57
  68. data/generators/airbrake/airbrake_generator.rb +0 -94
  69. data/generators/airbrake/lib/insert_commands.rb +0 -34
  70. data/generators/airbrake/lib/rake_commands.rb +0 -24
  71. data/generators/airbrake/templates/airbrake_tasks.rake +0 -25
  72. data/generators/airbrake/templates/capistrano_hook.rb +0 -6
  73. data/generators/airbrake/templates/initializer.rb +0 -4
  74. data/install.rb +0 -1
  75. data/lib/airbrake/backtrace.rb +0 -103
  76. data/lib/airbrake/capistrano.rb +0 -103
  77. data/lib/airbrake/capistrano3.rb +0 -3
  78. data/lib/airbrake/cli/client.rb +0 -76
  79. data/lib/airbrake/cli/options.rb +0 -45
  80. data/lib/airbrake/cli/printer.rb +0 -33
  81. data/lib/airbrake/cli/project.rb +0 -17
  82. data/lib/airbrake/cli/project_factory.rb +0 -33
  83. data/lib/airbrake/cli/runner.rb +0 -49
  84. data/lib/airbrake/cli/validator.rb +0 -8
  85. data/lib/airbrake/configuration.rb +0 -366
  86. data/lib/airbrake/jobs/send_job.rb +0 -7
  87. data/lib/airbrake/notice.rb +0 -411
  88. data/lib/airbrake/rack.rb +0 -64
  89. data/lib/airbrake/rails/action_controller_catcher.rb +0 -32
  90. data/lib/airbrake/rails/controller_methods.rb +0 -146
  91. data/lib/airbrake/rails/error_lookup.rb +0 -35
  92. data/lib/airbrake/rails/middleware.rb +0 -63
  93. data/lib/airbrake/rails.rb +0 -45
  94. data/lib/airbrake/rails3_tasks.rb +0 -126
  95. data/lib/airbrake/railtie.rb +0 -46
  96. data/lib/airbrake/rake_handler.rb +0 -75
  97. data/lib/airbrake/response.rb +0 -29
  98. data/lib/airbrake/sender.rb +0 -213
  99. data/lib/airbrake/shared_tasks.rb +0 -59
  100. data/lib/airbrake/sidekiq.rb +0 -8
  101. data/lib/airbrake/sinatra.rb +0 -40
  102. data/lib/airbrake/tasks/airbrake.cap +0 -28
  103. data/lib/airbrake/tasks.rb +0 -81
  104. data/lib/airbrake/user_informer.rb +0 -36
  105. data/lib/airbrake/utils/params_cleaner.rb +0 -141
  106. data/lib/airbrake/utils/rack_filters.rb +0 -45
  107. data/lib/airbrake_tasks.rb +0 -62
  108. data/lib/rails/generators/airbrake/airbrake_generator.rb +0 -155
  109. data/lib/templates/rescue.erb +0 -91
  110. data/rails/init.rb +0 -1
  111. data/resources/README.md +0 -34
  112. data/resources/airbrake_2_4.xsd +0 -89
  113. data/resources/airbrake_3_0.json +0 -52
  114. data/resources/ca-bundle.crt +0 -3376
  115. data/script/integration_test.rb +0 -35
  116. data/test/airbrake_tasks_test.rb +0 -161
  117. data/test/backtrace_test.rb +0 -215
  118. data/test/capistrano_test.rb +0 -44
  119. data/test/configuration_test.rb +0 -303
  120. data/test/controller_methods_test.rb +0 -230
  121. data/test/helper.rb +0 -233
  122. data/test/integration/catcher_test.rb +0 -371
  123. data/test/integration.rb +0 -13
  124. data/test/logger_test.rb +0 -79
  125. data/test/notice_test.rb +0 -494
  126. data/test/notifier_test.rb +0 -288
  127. data/test/params_cleaner_test.rb +0 -204
  128. data/test/rack_test.rb +0 -62
  129. data/test/rails_initializer_test.rb +0 -36
  130. data/test/recursion_test.rb +0 -10
  131. data/test/response_test.rb +0 -18
  132. data/test/sender_test.rb +0 -335
  133. data/test/support/response_shim.xml +0 -4
  134. data/test/user_informer_test.rb +0 -29
@@ -1,366 +0,0 @@
1
- module Airbrake
2
- # Used to set up and modify settings for the notifier.
3
- class Configuration
4
-
5
- OPTIONS = [:api_key, :backtrace_filters, :development_environments,
6
- :development_lookup, :environment_name, :host,
7
- :http_open_timeout, :http_read_timeout, :ignore, :ignore_by_filters,
8
- :ignore_user_agent, :notifier_name, :notifier_url, :notifier_version,
9
- :params_filters, :params_whitelist_filters, :project_root, :port, :protocol, :proxy_host,
10
- :proxy_pass, :proxy_port, :proxy_user, :secure, :use_system_ssl_cert_chain,
11
- :framework, :user_information, :rescue_rake_exceptions, :rake_environment_filters,
12
- :test_mode].freeze
13
-
14
- # The API key for your project, found on the project edit form.
15
- attr_accessor :api_key
16
-
17
- # The host to connect to (defaults to airbrake.io).
18
- attr_accessor :host
19
-
20
- # The port on which your Airbrake server runs (defaults to 443 for secure
21
- # connections, 80 for insecure connections).
22
- attr_writer :port
23
-
24
- # +true+ for https connections, +false+ for http connections.
25
- attr_accessor :secure
26
-
27
- # +true+ to use whatever CAs OpenSSL has installed on your system. +false+ to use the ca-bundle.crt file included in Airbrake itself (reccomended and default)
28
- attr_accessor :use_system_ssl_cert_chain
29
-
30
- # The HTTP open timeout in seconds (defaults to 2).
31
- attr_accessor :http_open_timeout
32
-
33
- # The HTTP read timeout in seconds (defaults to 5).
34
- attr_accessor :http_read_timeout
35
-
36
- # The hostname of your proxy server (if using a proxy)
37
- attr_accessor :proxy_host
38
-
39
- # The port of your proxy server (if using a proxy)
40
- attr_accessor :proxy_port
41
-
42
- # The username to use when logging into your proxy server (if using a proxy)
43
- attr_accessor :proxy_user
44
-
45
- # The password to use when logging into your proxy server (if using a proxy)
46
- attr_accessor :proxy_pass
47
-
48
- # A list of parameters that should be filtered out of what is sent to Airbrake.
49
- # By default, all "password" attributes will have their contents replaced.
50
- attr_accessor :params_filters
51
-
52
- # A list of whitelisted parameters that will be sent to Airbrake.
53
- # All other parameters will be filtered and their content replaced.
54
- # By default this list is empty (all parameters are whitelisted).
55
- attr_accessor :params_whitelist_filters
56
-
57
- # A list of filters for cleaning and pruning the backtrace. See #filter_backtrace.
58
- attr_reader :backtrace_filters
59
-
60
- # A list of filters for ignoring exceptions. See #ignore_by_filter.
61
- attr_reader :ignore_by_filters
62
-
63
- # A list of environment keys that will be ignored from what is sent to Airbrake server
64
- # Empty by default and used only in rake handler
65
- attr_reader :rake_environment_filters
66
-
67
- # A list of exception classes to ignore during server requests. The array can be appended to.
68
- attr_reader :ignore
69
-
70
- # A list of exception classes to ignore during Rake tasks. The array can be appended to.
71
- attr_reader :ignore_rake
72
-
73
- # A list of user agents that are being ignored. The array can be appended to.
74
- attr_reader :ignore_user_agent
75
-
76
- # A list of environments in which notifications should not be sent.
77
- attr_accessor :development_environments
78
-
79
- # +true+ if you want to check for production errors matching development errors, +false+ otherwise.
80
- attr_accessor :development_lookup
81
-
82
- # The name of the environment the application is running in
83
- attr_accessor :environment_name
84
-
85
- # The path to the project in which the error occurred, such as the Rails.root
86
- attr_accessor :project_root
87
-
88
- # The name of the notifier library being used to send notifications (such as "Airbrake Notifier")
89
- attr_accessor :notifier_name
90
-
91
- # The version of the notifier library being used to send notifications (such as "1.0.2")
92
- attr_accessor :notifier_version
93
-
94
- # The url of the notifier library being used to send notifications
95
- attr_accessor :notifier_url
96
-
97
- # The logger used by Airbrake
98
- attr_accessor :logger
99
-
100
- # The text that the placeholder is replaced with. {{error_id}} is the actual error number.
101
- attr_accessor :user_information
102
-
103
- # The framework Airbrake is configured to use
104
- attr_accessor :framework
105
-
106
- # Should Airbrake catch exceptions from Rake tasks?
107
- # (boolean or nil; set to nil to catch exceptions when rake isn't running from a terminal; default is nil)
108
- attr_accessor :rescue_rake_exceptions
109
- alias_method :rescue_rake_exceptions?, :rescue_rake_exceptions
110
-
111
- # User attributes that are being captured
112
- attr_reader :user_attributes
113
-
114
- # Only used for JSON API
115
- attr_reader :project_id
116
-
117
- # Setting this to true will use the CollectingSender instead of
118
- # the default one which will cause storing the last notice locally
119
- attr_accessor :test_mode
120
- alias_method :test_mode?, :test_mode
121
-
122
- DEFAULT_PARAMS_FILTERS = %w(password password_confirmation).freeze
123
- DEFAULT_PARAMS_WHITELIST_FILTERS = [].freeze
124
-
125
- DEFAULT_USER_ATTRIBUTES = %w(id).freeze
126
-
127
- VALID_USER_ATTRIBUTES = %w(id name username email).freeze
128
-
129
- DEFAULT_BACKTRACE_FILTERS = [
130
- lambda { |line|
131
- if defined?(Airbrake.configuration.project_root) && Airbrake.configuration.project_root.to_s != ''
132
- line.sub(/#{Airbrake.configuration.project_root}/, "[PROJECT_ROOT]")
133
- else
134
- line
135
- end
136
- },
137
- lambda { |line| line.gsub(/^\.\//, "") },
138
- lambda { |line|
139
- Gem.path.each{ |path| line.sub!(/#{path}/, "[GEM_ROOT]") unless path.to_s.strip.empty? } if defined?(Gem)
140
- line
141
- },
142
- lambda { |line| line if line !~ %r{lib/airbrake} }
143
- ].freeze
144
-
145
- IGNORE_DEFAULT = ['ActiveRecord::RecordNotFound',
146
- 'ActionController::RoutingError',
147
- 'ActionController::InvalidAuthenticityToken',
148
- 'CGI::Session::CookieStore::TamperedWithCookie',
149
- 'ActionController::UnknownHttpMethod',
150
- 'ActionController::UnknownAction',
151
- 'AbstractController::ActionNotFound',
152
- 'Mongoid::Errors::DocumentNotFound',
153
- 'ActionController::UnknownFormat']
154
-
155
- alias_method :secure?, :secure
156
- alias_method :use_system_ssl_cert_chain?, :use_system_ssl_cert_chain
157
-
158
- def initialize
159
- @secure = false
160
- @use_system_ssl_cert_chain= false
161
- @host = 'api.airbrake.io'
162
- @port = nil
163
- @http_open_timeout = 2
164
- @http_read_timeout = 5
165
- @params_filters = DEFAULT_PARAMS_FILTERS.dup
166
- @params_whitelist_filters = DEFAULT_PARAMS_WHITELIST_FILTERS.dup
167
- @backtrace_filters = DEFAULT_BACKTRACE_FILTERS.dup
168
- @ignore_by_filters = [] # These filters are applied to both server requests and Rake tasks
169
- @ignore = IGNORE_DEFAULT.dup
170
- @ignore_rake = [] # Rake tasks don't ignore any exception classes by default
171
- @ignore_user_agent = []
172
- @development_environments = %w(development test cucumber)
173
- @development_lookup = true
174
- @notifier_name = 'Airbrake Notifier'
175
- @notifier_version = VERSION
176
- @notifier_url = 'https://github.com/airbrake/airbrake'
177
- @framework = 'Standalone'
178
- @user_information = 'Airbrake Error {{error_id}}'
179
- @rescue_rake_exceptions = nil
180
- @user_attributes = DEFAULT_USER_ATTRIBUTES.dup
181
- @rake_environment_filters = []
182
- @async = nil
183
- end
184
-
185
- # Takes a block and adds it to the list of backtrace filters. When the filters
186
- # run, the block will be handed each line of the backtrace and can modify
187
- # it as necessary.
188
- #
189
- # @example
190
- # config.filter_bracktrace do |line|
191
- # line.gsub(/^#{Rails.root}/, "[Rails.root]")
192
- # end
193
- #
194
- # @param [Proc] block The new backtrace filter.
195
- # @yieldparam [String] line A line in the backtrace.
196
- def filter_backtrace(&block)
197
- self.backtrace_filters << block
198
- end
199
-
200
- # Takes a block and adds it to the list of ignore filters.
201
- # When the filters run, the block will be handed the exception.
202
- # @example
203
- # config.ignore_by_filter do |exception_data|
204
- # true if exception_data[:error_class] == "RuntimeError"
205
- # end
206
- #
207
- # @param [Proc] block The new ignore filter
208
- # @yieldparam [Hash] data The exception data given to +Airbrake.notify+
209
- # @yieldreturn [Boolean] If the block returns true the exception will be ignored, otherwise it will be processed by airbrake.
210
- def ignore_by_filter(&block)
211
- self.ignore_by_filters << block
212
- end
213
-
214
- # Overrides the list of default ignored errors.
215
- #
216
- # @param [Array<Exception>] names A list of exceptions to ignore.
217
- def ignore_only=(names)
218
- @ignore = [names].flatten
219
- end
220
-
221
- # Overrides the list of default ignored errors during Rake tasks.
222
- #
223
- # @param [Array<Exception>] names A list of rake exceptions to ignore.
224
- def ignore_rake_only=(names)
225
- @ignore_rake = [names].flatten
226
- end
227
-
228
- # Overrides the list of default ignored user agents
229
- #
230
- # @param [Array<String>] A list of user agents to ignore
231
- def ignore_user_agent_only=(names)
232
- @ignore_user_agent = [names].flatten
233
- end
234
-
235
- # Allows config options to be read like a hash
236
- #
237
- # @param [Symbol] option Key for a given attribute
238
- def [](option)
239
- send(option)
240
- end
241
-
242
- # Returns a hash of all configurable options
243
- def to_hash
244
- OPTIONS.inject({}) do |hash, option|
245
- hash[option.to_sym] = self.send(option)
246
- hash
247
- end
248
- end
249
-
250
- # Returns a hash of all configurable options merged with +hash+
251
- #
252
- # @param [Hash] hash A set of configuration options that will take precedence over the defaults
253
- def merge(hash)
254
- to_hash.merge(hash)
255
- end
256
-
257
- # Determines if the notifier will send notices.
258
- # @return [Boolean] Returns +true+ if an api string exists, +false+ otherwise.
259
- def configured?
260
- !api_key.nil? && !api_key.empty?
261
- end
262
-
263
- # Determines if the notifier will send notices.
264
- # @return [Boolean] Returns +false+ if in a development environment, +true+ otherwise.
265
- def public?
266
- @public ||= !development_environments.include?(environment_name)
267
- end
268
-
269
- def port
270
- @port || default_port
271
- end
272
-
273
- # Determines whether protocol should be "http" or "https".
274
- # @return [String] Returns +"http"+ if you've set secure to +false+ in
275
- # configuration, and +"https"+ otherwise.
276
- def protocol
277
- if secure?
278
- 'https'
279
- else
280
- 'http'
281
- end
282
- end
283
-
284
- def user_attributes=(user_attributes)
285
- @user_attributes = validate_user_attributes user_attributes
286
- end
287
-
288
- # Should Airbrake send notifications asynchronously
289
- # (boolean, nil or callable; default is nil).
290
- # Can be used as callable-setter when block provided.
291
- def async(&block)
292
- if block_given?
293
- @async = block
294
- end
295
- @async
296
- end
297
- alias_method :async?, :async
298
-
299
- def async=(use_default_or_this)
300
- @async = use_default_or_this == true ?
301
- default_async_processor :
302
- use_default_or_this
303
- end
304
-
305
- def rescue_rake_exceptions=(val)
306
- if val && !defined?(Airbrake::RakeHandler)
307
- raise LoadError, "you must require 'airbrake/rake_handler' to rescue from rake exceptions"
308
- end
309
- @rescue_rake_exceptions = val
310
- end
311
-
312
- def ca_bundle_path
313
- if use_system_ssl_cert_chain?
314
- OpenSSL::X509::DEFAULT_CERT_FILE if File.exist?(OpenSSL::X509::DEFAULT_CERT_FILE)
315
- else
316
- local_cert_path # ca-bundle.crt built from source, see resources/README.md
317
- end
318
- end
319
-
320
- def local_cert_path
321
- File.expand_path(File.join("..", "..", "..", "resources", "ca-bundle.crt"), __FILE__)
322
- end
323
-
324
- def project_id=(project_id)
325
- @project_id = "#{project_id}"
326
- end
327
-
328
- private
329
- # Determines what port should we use for sending notices.
330
- # @return [Fixnum] Returns 443 if you've set secure to true in your
331
- # configuration, and 80 otherwise.
332
- def default_port
333
- if secure?
334
- 443
335
- else
336
- 80
337
- end
338
- end
339
-
340
- # Async notice delivery defaults to girl friday
341
- def default_async_processor
342
- if defined?(SuckerPunch)
343
- lambda {|notice| SendJob.new.async.perform(notice)}
344
- elsif defined?(GirlFriday)
345
- queue = GirlFriday::WorkQueue.new(nil, :size => 3) do |notice|
346
- Airbrake.sender.send_to_airbrake(notice)
347
- end
348
- lambda {|notice| queue << notice}
349
- else
350
- warn "[AIRBRAKE] You can't use the default async handler without sucker_punch or girl_friday."\
351
- " Please make sure you have sucker_punch or girl_friday installed (sucker_punch is recommended)."
352
- end
353
- end
354
-
355
- def validate_user_attributes(user_attributes)
356
- user_attributes.reject do |attribute|
357
- unless VALID_USER_ATTRIBUTES.include? attribute.to_s
358
- warn "[AIRBRAKE] Unsupported user attribute: '#{attribute}'. "\
359
- "This attribute will not be shown in the Airbrake UI. "\
360
- "Check http://git.io/h6YRpA for more info."
361
- true
362
- end
363
- end
364
- end
365
- end
366
- end
@@ -1,7 +0,0 @@
1
- class SendJob
2
- include SuckerPunch::Job if defined?(SuckerPunch)
3
-
4
- def perform(notice)
5
- Airbrake.sender.send_to_airbrake(notice)
6
- end
7
- end