bugsnag 5.5.0 → 6.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +33 -11
- data/CHANGELOG.md +23 -0
- data/Gemfile +20 -0
- data/Rakefile +19 -12
- data/UPGRADING.md +58 -0
- data/VERSION +1 -1
- data/bugsnag.gemspec +0 -9
- data/lib/bugsnag.rb +64 -86
- data/lib/bugsnag/configuration.rb +42 -26
- data/lib/bugsnag/delivery.rb +9 -0
- data/lib/bugsnag/delivery/synchronous.rb +3 -5
- data/lib/bugsnag/delivery/thread_queue.rb +4 -2
- data/lib/bugsnag/helpers.rb +5 -16
- data/lib/bugsnag/{delayed_job.rb → integrations/delayed_job.rb} +15 -7
- data/lib/bugsnag/{mailman.rb → integrations/mailman.rb} +13 -11
- data/lib/bugsnag/{que.rb → integrations/que.rb} +11 -11
- data/lib/bugsnag/{rack.rb → integrations/rack.rb} +22 -23
- data/lib/bugsnag/{rails → integrations/rails}/active_record_rescue.rb +9 -7
- data/lib/bugsnag/{rails → integrations/rails}/controller_methods.rb +0 -9
- data/lib/bugsnag/{railtie.rb → integrations/railtie.rb} +24 -21
- data/lib/bugsnag/{rake.rb → integrations/rake.rb} +12 -9
- data/lib/bugsnag/{resque.rb → integrations/resque.rb} +12 -9
- data/lib/bugsnag/integrations/shoryuken.rb +49 -0
- data/lib/bugsnag/{sidekiq.rb → integrations/sidekiq.rb} +13 -9
- data/lib/bugsnag/middleware/callbacks.rb +4 -8
- data/lib/bugsnag/middleware/classify_error.rb +7 -13
- data/lib/bugsnag/middleware/clearance_user.rb +8 -8
- data/lib/bugsnag/middleware/exception_meta_data.rb +34 -0
- data/lib/bugsnag/middleware/ignore_error_class.rb +21 -0
- data/lib/bugsnag/middleware/mailman.rb +4 -4
- data/lib/bugsnag/middleware/rack_request.rb +13 -13
- data/lib/bugsnag/middleware/rails3_request.rb +10 -10
- data/lib/bugsnag/middleware/rake.rb +5 -5
- data/lib/bugsnag/middleware/sidekiq.rb +5 -5
- data/lib/bugsnag/middleware/suggestion_data.rb +30 -0
- data/lib/bugsnag/middleware/warden_user.rb +6 -6
- data/lib/bugsnag/middleware_stack.rb +5 -5
- data/lib/bugsnag/report.rb +187 -0
- data/lib/bugsnag/stacktrace.rb +113 -0
- data/lib/bugsnag/tasks/bugsnag.rake +2 -70
- data/spec/cleaner_spec.rb +6 -0
- data/spec/configuration_spec.rb +1 -1
- data/spec/fixtures/middleware/internal_info_setter.rb +3 -3
- data/spec/fixtures/middleware/public_info_setter.rb +3 -3
- data/spec/fixtures/tasks/Rakefile +2 -3
- data/spec/integration_spec.rb +5 -20
- data/spec/{delayed_job_spec.rb → integrations/delayed_job_spec.rb} +0 -0
- data/spec/integrations/sidekiq_spec.rb +34 -0
- data/spec/middleware_spec.rb +108 -35
- data/spec/rack_spec.rb +1 -1
- data/spec/{notification_spec.rb → report_spec.rb} +226 -209
- data/spec/spec_helper.rb +18 -0
- data/spec/{code_spec.rb → stacktrace_spec.rb} +1 -1
- metadata +23 -139
- data/.document +0 -5
- data/lib/bugsnag/capistrano.rb +0 -7
- data/lib/bugsnag/capistrano2.rb +0 -32
- data/lib/bugsnag/delay/resque.rb +0 -21
- data/lib/bugsnag/deploy.rb +0 -35
- data/lib/bugsnag/middleware/rails2_request.rb +0 -52
- data/lib/bugsnag/notification.rb +0 -506
- data/lib/bugsnag/rails.rb +0 -70
- data/lib/bugsnag/rails/action_controller_rescue.rb +0 -74
- data/lib/bugsnag/shoryuken.rb +0 -41
- data/lib/bugsnag/tasks/bugsnag.cap +0 -48
- data/rails/init.rb +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bdb80b010ab8da05acfddaa542a8b7cbff4be599
|
4
|
+
data.tar.gz: 7fa7188b650b1ebc07e074f4d6f2f1a365105033
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9f19d8a8b92a80747fb160ca3d55c5b19c35aefe8c9293eff1843668a76e90965b37a643e90ebc912b4e1e621411d0968241e024d01b490b5a1d0484621a2b2f
|
7
|
+
data.tar.gz: 2b46521a1dbe916993b13f546992533ef2ab0422cf45a27ea6a30c1c13f8ba01c0a42c2e2486ac655eccff531443452a00fe765e51fea039346d205803da9373
|
data/.travis.yml
CHANGED
@@ -1,16 +1,38 @@
|
|
1
1
|
sudo: false
|
2
2
|
language: ruby
|
3
|
-
cache: bundler
|
4
|
-
rvm:
|
5
|
-
- 2.3.0
|
6
|
-
- 2.2.4
|
7
|
-
- 2.1.8
|
8
|
-
- 2.0.0
|
9
|
-
- 1.9.3
|
10
|
-
- jruby-19mode
|
11
3
|
|
12
4
|
before_install:
|
13
|
-
- gem
|
14
|
-
- gem update --system
|
15
|
-
- bundle --version
|
5
|
+
- gem update --system 2.6.14
|
16
6
|
- gem --version
|
7
|
+
- gem install bundler -v 1.12
|
8
|
+
- bundle _1.12.0_ --version
|
9
|
+
|
10
|
+
install:
|
11
|
+
- bundle _1.12.0_ install --with "$GEMSETS" --binstubs
|
12
|
+
|
13
|
+
script:
|
14
|
+
- bundle exec ./bin/rake spec
|
15
|
+
|
16
|
+
jobs:
|
17
|
+
include:
|
18
|
+
- stage: test
|
19
|
+
env: GEMSETS=test
|
20
|
+
rvm: jruby-19mode
|
21
|
+
- stage: test
|
22
|
+
env: GEMSETS=test
|
23
|
+
rvm: 1.9.3
|
24
|
+
- stage: test
|
25
|
+
env: GEMSETS=test
|
26
|
+
rvm: 2.0.0
|
27
|
+
- stage: test
|
28
|
+
env: GEMSETS=test
|
29
|
+
rvm: 2.1.10
|
30
|
+
- stage: test
|
31
|
+
env: GEMSETS="test sidekiq"
|
32
|
+
rvm: 2.2.4
|
33
|
+
- stage: test
|
34
|
+
env: GEMSETS="test sidekiq coverage"
|
35
|
+
rvm: 2.3.0
|
36
|
+
- stage: test
|
37
|
+
env: GEMSETS="test sidekiq"
|
38
|
+
rvm: 2.4.1
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,29 @@
|
|
1
1
|
Changelog
|
2
2
|
=========
|
3
3
|
|
4
|
+
## 6.0.0 (09 Nov 2017)
|
5
|
+
|
6
|
+
This notifier has been extensively re-written to make it easier to add new integrations and maintain in the future. This has led to several changes that are not backwards compatible. Please refer to the [upgrading guide](https://github.com/bugsnag/bugsnag-ruby/blob/master/UPGRADING.md) for more information.
|
7
|
+
|
8
|
+
### Enhancements
|
9
|
+
|
10
|
+
* General notifier re-write
|
11
|
+
| [#320](https://github.com/bugsnag/bugsnag-ruby/pull/320)
|
12
|
+
| [#378](https://github.com/bugsnag/bugsnag-ruby/pull/378)
|
13
|
+
| [#368](https://github.com/bugsnag/bugsnag-ruby/pull/368)
|
14
|
+
| [#381](https://github.com/bugsnag/bugsnag-ruby/pull/381)
|
15
|
+
| [#385](https://github.com/bugsnag/bugsnag-ruby/pull/385)
|
16
|
+
| [#386](https://github.com/bugsnag/bugsnag-ruby/pull/386)
|
17
|
+
|
18
|
+
* Added Upgrade guide
|
19
|
+
| [#370](https://github.com/bugsnag/bugsnag-ruby/pull/370)
|
20
|
+
|
21
|
+
* Did-you-mean suggestions middleware
|
22
|
+
| [#372](https://github.com/bugsnag/bugsnag-ruby/pull/372)
|
23
|
+
|
24
|
+
* Updated examples
|
25
|
+
| [#374](https://github.com/bugsnag/bugsnag-ruby/pull/374)
|
26
|
+
|
4
27
|
## 5.5.0 (09 Nov 2017)
|
5
28
|
|
6
29
|
### Enhancements
|
data/Gemfile
CHANGED
@@ -1,2 +1,22 @@
|
|
1
1
|
source "https://rubygems.org"
|
2
|
+
|
3
|
+
group :test, optional: true do
|
4
|
+
gem 'rake', '~> 10.1.1'
|
5
|
+
gem 'rspec'
|
6
|
+
gem 'rdoc'
|
7
|
+
gem 'pry'
|
8
|
+
gem 'addressable', '~> 2.3.8'
|
9
|
+
gem 'delayed_job' if RUBY_VERSION >= '2.2.2'
|
10
|
+
gem 'webmock', RUBY_VERSION <= '1.9.3' ? '2.3.2': '>2.3.2'
|
11
|
+
end
|
12
|
+
|
13
|
+
group :coverage, optional: true do
|
14
|
+
gem 'simplecov'
|
15
|
+
gem 'coveralls'
|
16
|
+
end
|
17
|
+
|
18
|
+
group :sidekiq, optional: true do
|
19
|
+
gem 'sidekiq', '~> 5.0.4'
|
20
|
+
end
|
21
|
+
|
2
22
|
gemspec
|
data/Rakefile
CHANGED
@@ -1,16 +1,5 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
require 'rubygems'
|
4
|
-
require 'bundler'
|
5
|
-
require 'bundler/gem_tasks'
|
6
|
-
begin
|
7
|
-
Bundler.setup(:default, :development)
|
8
|
-
rescue Bundler::BundlerError => e
|
9
|
-
$stderr.puts e.message
|
10
|
-
$stderr.puts "Run `bundle install` to install missing gems"
|
11
|
-
exit e.status_code
|
12
|
-
end
|
13
|
-
|
14
3
|
require 'rdoc/task'
|
15
4
|
RDoc::Task.new do |rdoc|
|
16
5
|
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
@@ -24,6 +13,24 @@ end
|
|
24
13
|
# RSpec tasks
|
25
14
|
require 'rspec/core'
|
26
15
|
require "rspec/core/rake_task"
|
27
|
-
RSpec::Core::RakeTask.new(:spec)
|
16
|
+
RSpec::Core::RakeTask.new(:spec) do |task|
|
17
|
+
integration_exclusions = []
|
18
|
+
begin
|
19
|
+
require 'sidekiq/testing'
|
20
|
+
rescue LoadError
|
21
|
+
puts "Skipping sidekiq tests, missing dependencies"
|
22
|
+
integration_exclusions << 'sidekiq'
|
23
|
+
end
|
24
|
+
begin
|
25
|
+
require 'delayed_job'
|
26
|
+
rescue LoadError
|
27
|
+
puts "Skipping delayed_job tests, missing dependencies"
|
28
|
+
integration_exclusions << 'delayed_job'
|
29
|
+
end
|
30
|
+
if integration_exclusions.length > 0
|
31
|
+
pattern = integration_exclusions.join(',')
|
32
|
+
task.rspec_opts = " --exclude-pattern **/integrations/{#{pattern}}_spec.rb"
|
33
|
+
end
|
34
|
+
end
|
28
35
|
|
29
36
|
task :default => :spec
|
data/UPGRADING.md
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
# Upgrade Guide
|
2
|
+
|
3
|
+
## 5.x to 6.x
|
4
|
+
|
5
|
+
_Our Ruby library has gone through some major improvements and there are a few
|
6
|
+
changes required to use the new integrations_
|
7
|
+
|
8
|
+
#### Capistrano and deploys
|
9
|
+
|
10
|
+
Support for notifying Bugsnag of deployments has been separated into a separate
|
11
|
+
gem named `bugsnag-capistrano`. See the [integration
|
12
|
+
guide](https://docs.bugsnag.com/platforms/ruby/capistrano) for more information.
|
13
|
+
|
14
|
+
|
15
|
+
#### Configuration
|
16
|
+
|
17
|
+
* `Configuration.use_ssl` has been removed. Include the preferred protocol in `Configuration.endpoint` instead.
|
18
|
+
```diff
|
19
|
+
Bugsnag.configure do |config|
|
20
|
+
- config.use_ssl = true
|
21
|
+
- config.endpoint = 'myserver.example.com'
|
22
|
+
+ config.endpoint = 'https://myserver.example.com'
|
23
|
+
end
|
24
|
+
```
|
25
|
+
* `Configuration.ignore_classes` now no longer accepts strings. Use classes directly instead.
|
26
|
+
* `Configuration.delay_with_resque` has been removed
|
27
|
+
* `Configuration.vendor_paths` has been removed
|
28
|
+
* `Configuration.params_filters` has been renamed to `Configuration.meta_data_filters` to be clearer
|
29
|
+
* `Configuration.proxy_host` will now default to `ENV['http_proxy']` if set. It can still be manually set.
|
30
|
+
|
31
|
+
#### Notifying
|
32
|
+
|
33
|
+
* `notify` now only supports block syntax. Replace usage of the overrides hash with a block
|
34
|
+
|
35
|
+
```diff
|
36
|
+
- Bugsnag.notify(e, {severity: 'info'})
|
37
|
+
+ Bugsnag.notify(e) do |report|
|
38
|
+
+ report.severity = 'info'
|
39
|
+
+ end
|
40
|
+
```
|
41
|
+
|
42
|
+
* `Bugsnag.notify_or_ignore` and `Bugsnag.auto_notify` have been removed removed. Call `notify` directly instead.
|
43
|
+
* `after_notify_callbacks` has been removed
|
44
|
+
* `Bugsnag::Notification` has been renamed to `Bugsnag::Report`
|
45
|
+
|
46
|
+
#### Logging
|
47
|
+
|
48
|
+
* `config.debug` boolean has been removed. Set the logger level directly
|
49
|
+
|
50
|
+
```diff
|
51
|
+
+ require 'logger'
|
52
|
+
|
53
|
+
Bugsnag.configure do |config|
|
54
|
+
# .. set API key and other properties
|
55
|
+
- config.debug = true
|
56
|
+
+ config.logger.level = Logger::DEBUG
|
57
|
+
end
|
58
|
+
```
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
6.0.0
|
data/bugsnag.gemspec
CHANGED
@@ -18,13 +18,4 @@ Gem::Specification.new do |s|
|
|
18
18
|
]
|
19
19
|
s.require_paths = ["lib"]
|
20
20
|
s.required_ruby_version = '>= 1.9.2'
|
21
|
-
|
22
|
-
s.add_development_dependency 'rake', '~> 10.1.1'
|
23
|
-
s.add_development_dependency 'rspec'
|
24
|
-
s.add_development_dependency 'rdoc'
|
25
|
-
s.add_development_dependency 'pry'
|
26
|
-
s.add_development_dependency 'addressable', '~> 2.3.8'
|
27
|
-
s.add_development_dependency 'webmock', '2.1.0'
|
28
|
-
s.add_development_dependency 'delayed_job'
|
29
|
-
s.add_development_dependency 'activesupport', '~> 4.2.10'
|
30
21
|
end
|
data/lib/bugsnag.rb
CHANGED
@@ -4,16 +4,16 @@ require "thread"
|
|
4
4
|
require "bugsnag/version"
|
5
5
|
require "bugsnag/configuration"
|
6
6
|
require "bugsnag/meta_data"
|
7
|
-
require "bugsnag/
|
7
|
+
require "bugsnag/report"
|
8
8
|
require "bugsnag/cleaner"
|
9
9
|
require "bugsnag/helpers"
|
10
|
-
require "bugsnag/deploy"
|
11
10
|
|
12
11
|
require "bugsnag/delivery"
|
13
12
|
require "bugsnag/delivery/synchronous"
|
14
13
|
require "bugsnag/delivery/thread_queue"
|
15
14
|
|
16
|
-
require "bugsnag/rack"
|
15
|
+
require "bugsnag/integrations/rack"
|
16
|
+
require "bugsnag/integrations/railtie" if defined?(Rails::Railtie)
|
17
17
|
|
18
18
|
require "bugsnag/middleware/rack_request"
|
19
19
|
require "bugsnag/middleware/warden_user"
|
@@ -27,92 +27,88 @@ require "bugsnag/middleware/callbacks"
|
|
27
27
|
require "bugsnag/middleware/classify_error"
|
28
28
|
|
29
29
|
module Bugsnag
|
30
|
-
LOG_PREFIX = "** [Bugsnag] "
|
31
30
|
LOCK = Mutex.new
|
32
31
|
|
33
32
|
class << self
|
34
33
|
# Configure the Bugsnag notifier application-wide settings.
|
35
|
-
def configure
|
36
|
-
if config_hash
|
37
|
-
config_hash.each do |k,v|
|
38
|
-
configuration.send("#{k}=", v) rescue nil if configuration.respond_to?("#{k}=")
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
34
|
+
def configure
|
42
35
|
yield(configuration) if block_given?
|
43
36
|
|
44
|
-
# Use resque for asynchronous notification if required
|
45
|
-
require "bugsnag/delay/resque" if configuration.delay_with_resque && defined?(Resque)
|
46
|
-
|
47
|
-
# Add info error classifier to internal middleware
|
48
|
-
configuration.internal_middleware.use(Bugsnag::Middleware::ClassifyError)
|
49
|
-
|
50
|
-
# Warn if an api_key hasn't been set
|
51
37
|
@key_warning = false unless defined?(@key_warning)
|
52
|
-
|
53
|
-
|
54
|
-
warn "No API key has been set, check your configuration"
|
38
|
+
if !configuration.valid_api_key? && !@key_warning
|
39
|
+
configuration.warn("No valid API key has been set, notifications will not be sent")
|
55
40
|
@key_warning = true
|
56
41
|
end
|
42
|
+
end
|
57
43
|
|
58
|
-
|
59
|
-
|
44
|
+
# Explicitly notify of an exception
|
45
|
+
def notify(exception, auto_notify=false, &block)
|
60
46
|
|
61
|
-
if configuration.
|
62
|
-
|
63
|
-
|
47
|
+
if !configuration.auto_notify && auto_notify
|
48
|
+
configuration.debug("Not notifying because auto_notify is disabled")
|
49
|
+
return
|
64
50
|
end
|
65
|
-
end
|
66
51
|
|
67
|
-
|
68
|
-
|
69
|
-
|
52
|
+
if !configuration.valid_api_key?
|
53
|
+
configuration.debug("Not notifying due to an invalid api_key")
|
54
|
+
return
|
55
|
+
end
|
70
56
|
|
71
|
-
|
72
|
-
|
57
|
+
if !configuration.should_notify_release_stage?
|
58
|
+
configuration.debug("Not notifying due to notify_release_stages :#{configuration.notify_release_stages.inspect}")
|
59
|
+
return
|
60
|
+
end
|
73
61
|
|
74
|
-
|
62
|
+
report = Report.new(exception, configuration, auto_notify)
|
75
63
|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
}
|
80
|
-
|
81
|
-
notification.severity_reason = initial_reason
|
64
|
+
# If this is an auto_notify we yield the block before the any middleware is run
|
65
|
+
yield(report) if block_given? && auto_notify
|
66
|
+
if report.ignore?
|
67
|
+
configuration.debug("Not notifying #{report.exceptions.last[:errorClass]} due to ignore being signified in auto_notify block")
|
68
|
+
return
|
82
69
|
end
|
83
70
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
71
|
+
# Run internal middleware
|
72
|
+
configuration.internal_middleware.run(report)
|
73
|
+
if report.ignore?
|
74
|
+
configuration.debug("Not notifying #{report.exceptions.last[:errorClass]} due to ignore being signified in internal middlewares")
|
75
|
+
return
|
89
76
|
end
|
90
|
-
end
|
91
|
-
alias_method :notify_or_ignore, :notify
|
92
|
-
|
93
|
-
# Auto notify of an exception, called from rails and rack exception
|
94
|
-
# rescuers, unless auto notification is disabled, or we should ignore this
|
95
|
-
# error class
|
96
|
-
def auto_notify(exception, overrides=nil, request_data=nil, &block)
|
97
|
-
overrides ||= {}
|
98
|
-
overrides[:severity] = "error" unless overrides.has_key? :severity
|
99
|
-
overrides[:unhandled] = true unless overrides.has_key? :unhandled
|
100
|
-
notify_or_ignore(exception, overrides, request_data, &block) if configuration.auto_notify
|
101
|
-
end
|
102
77
|
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
end
|
78
|
+
# Store before_middleware severity reason for future reference
|
79
|
+
initial_severity = report.severity
|
80
|
+
initial_reason = report.severity_reason
|
107
81
|
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
82
|
+
# Run users middleware
|
83
|
+
configuration.middleware.run(report) do
|
84
|
+
if report.ignore?
|
85
|
+
configuration.debug("Not notifying #{report.exceptions.last[:errorClass]} due to ignore being signified in user provided middleware")
|
86
|
+
return
|
87
|
+
end
|
88
|
+
|
89
|
+
# If this is not an auto_notify then the block was provided by the user. This should be the last
|
90
|
+
# block that is run as it is the users "most specific" block.
|
91
|
+
yield(report) if block_given? && !auto_notify
|
92
|
+
if report.ignore?
|
93
|
+
configuration.debug("Not notifying #{report.exceptions.last[:errorClass]} due to ignore being signified in user provided block")
|
94
|
+
return
|
95
|
+
end
|
96
|
+
|
97
|
+
# Test whether severity has been changed and ensure severity_reason is consistant in auto_notify case
|
98
|
+
if report.severity != initial_severity
|
99
|
+
report.severity_reason = {
|
100
|
+
:type => Report::USER_CALLBACK_SET_SEVERITY
|
101
|
+
}
|
102
|
+
else
|
103
|
+
report.severity_reason = initial_reason
|
104
|
+
end
|
112
105
|
|
113
|
-
|
114
|
-
|
115
|
-
|
106
|
+
# Deliver
|
107
|
+
configuration.info("Notifying #{configuration.endpoint} of #{report.exceptions.last[:errorClass]}")
|
108
|
+
payload_string = ::JSON.dump(Bugsnag::Helpers.trim_if_needed(report.as_json))
|
109
|
+
configuration.debug("Payload: #{payload_string}")
|
110
|
+
Bugsnag::Delivery[configuration.delivery_method].deliver(configuration.endpoint, payload_string, configuration)
|
111
|
+
end
|
116
112
|
end
|
117
113
|
|
118
114
|
# Configuration getters
|
@@ -121,34 +117,16 @@ module Bugsnag
|
|
121
117
|
@configuration || LOCK.synchronize { @configuration ||= Bugsnag::Configuration.new }
|
122
118
|
end
|
123
119
|
|
124
|
-
# Set "per-request" data, temporal data for use in bugsnag middleware
|
125
|
-
def set_request_data(key, value)
|
126
|
-
Bugsnag.configuration.set_request_data(key, value)
|
127
|
-
end
|
128
|
-
|
129
|
-
# Clear all "per-request" data, temporal data for use in bugsnag middleware
|
130
|
-
# This method should be called after each distinct request or session ends
|
131
|
-
# Eg. After completing a page request in a web app
|
132
|
-
def clear_request_data
|
133
|
-
Bugsnag.configuration.clear_request_data
|
134
|
-
end
|
135
|
-
|
136
120
|
# Allow access to "before notify" callbacks
|
137
121
|
def before_notify_callbacks
|
138
122
|
Bugsnag.configuration.request_data[:before_callbacks] ||= []
|
139
123
|
end
|
140
|
-
|
141
|
-
# Allow access to "after notify" callbacks
|
142
|
-
def after_notify_callbacks
|
143
|
-
Bugsnag.configuration.request_data[:after_callbacks] ||= []
|
144
|
-
end
|
145
124
|
end
|
146
125
|
end
|
147
126
|
|
148
|
-
require "bugsnag/railtie" if defined?(Rails::Railtie)
|
149
127
|
[:resque, :sidekiq, :mailman, :delayed_job, :shoryuken, :que].each do |integration|
|
150
128
|
begin
|
151
|
-
require "bugsnag/#{integration}"
|
129
|
+
require "bugsnag/integrations/#{integration}"
|
152
130
|
rescue LoadError
|
153
131
|
end
|
154
132
|
end
|
@@ -2,6 +2,11 @@ require "set"
|
|
2
2
|
require "socket"
|
3
3
|
require "logger"
|
4
4
|
require "bugsnag/middleware_stack"
|
5
|
+
require "bugsnag/middleware/callbacks"
|
6
|
+
require "bugsnag/middleware/exception_meta_data"
|
7
|
+
require "bugsnag/middleware/ignore_error_class"
|
8
|
+
require "bugsnag/middleware/suggestion_data"
|
9
|
+
require "bugsnag/middleware/classify_error"
|
5
10
|
|
6
11
|
module Bugsnag
|
7
12
|
class Configuration
|
@@ -9,35 +14,30 @@ module Bugsnag
|
|
9
14
|
attr_accessor :release_stage
|
10
15
|
attr_accessor :notify_release_stages
|
11
16
|
attr_accessor :auto_notify
|
12
|
-
attr_accessor :use_ssl
|
13
17
|
attr_accessor :ca_file
|
14
18
|
attr_accessor :send_environment
|
15
19
|
attr_accessor :send_code
|
16
20
|
attr_accessor :project_root
|
17
|
-
attr_accessor :vendor_paths
|
18
21
|
attr_accessor :app_version
|
19
22
|
attr_accessor :app_type
|
20
|
-
attr_accessor :
|
21
|
-
attr_accessor :ignore_user_agents
|
23
|
+
attr_accessor :meta_data_filters
|
22
24
|
attr_accessor :endpoint
|
23
25
|
attr_accessor :logger
|
24
26
|
attr_accessor :middleware
|
25
27
|
attr_accessor :internal_middleware
|
26
|
-
attr_accessor :delay_with_resque
|
27
|
-
attr_accessor :debug
|
28
28
|
attr_accessor :proxy_host
|
29
29
|
attr_accessor :proxy_port
|
30
30
|
attr_accessor :proxy_user
|
31
31
|
attr_accessor :proxy_password
|
32
32
|
attr_accessor :timeout
|
33
33
|
attr_accessor :hostname
|
34
|
-
|
34
|
+
attr_accessor :ignore_classes
|
35
35
|
|
36
|
+
API_KEY_REGEX = /[0-9a-f]{32}/i
|
36
37
|
THREAD_LOCAL_NAME = "bugsnag_req_data"
|
38
|
+
DEFAULT_ENDPOINT = "https://notify.bugsnag.com"
|
37
39
|
|
38
|
-
|
39
|
-
|
40
|
-
DEFAULT_PARAMS_FILTERS = [
|
40
|
+
DEFAULT_META_DATA_FILTERS = [
|
41
41
|
/authorization/i,
|
42
42
|
/cookie/i,
|
43
43
|
/password/i,
|
@@ -45,36 +45,39 @@ module Bugsnag
|
|
45
45
|
"rack.request.form_vars"
|
46
46
|
].freeze
|
47
47
|
|
48
|
-
DEFAULT_IGNORE_USER_AGENTS = [].freeze
|
49
|
-
|
50
|
-
DEFAULT_DELIVERY_METHOD = :thread_queue
|
51
|
-
|
52
48
|
def initialize
|
53
49
|
@mutex = Mutex.new
|
54
50
|
|
55
51
|
# Set up the defaults
|
56
52
|
self.auto_notify = true
|
57
|
-
self.use_ssl = true
|
58
53
|
self.send_environment = false
|
59
54
|
self.send_code = true
|
60
|
-
self.
|
61
|
-
self.ignore_classes = Set.new()
|
62
|
-
self.ignore_user_agents = Set.new(DEFAULT_IGNORE_USER_AGENTS)
|
55
|
+
self.meta_data_filters = Set.new(DEFAULT_META_DATA_FILTERS)
|
56
|
+
self.ignore_classes = Set.new([])
|
63
57
|
self.endpoint = DEFAULT_ENDPOINT
|
64
58
|
self.hostname = default_hostname
|
65
59
|
self.timeout = 15
|
66
|
-
self.vendor_paths = [%r{vendor/}]
|
67
60
|
self.notify_release_stages = nil
|
68
61
|
|
69
62
|
# Read the API key from the environment
|
70
63
|
self.api_key = ENV["BUGSNAG_API_KEY"]
|
71
64
|
|
65
|
+
# Read NET::HTTP proxy environment variable
|
66
|
+
self.proxy_host = ENV["http_proxy"]
|
67
|
+
|
72
68
|
# Set up logging
|
73
69
|
self.logger = Logger.new(STDOUT)
|
74
|
-
self.logger.level = Logger::
|
70
|
+
self.logger.level = Logger::INFO
|
71
|
+
self.logger.formatter = proc do |severity, datetime, progname, msg|
|
72
|
+
"** [Bugsnag] #{datetime}: #{msg}\n"
|
73
|
+
end
|
75
74
|
|
76
75
|
# Configure the bugsnag middleware stack
|
77
76
|
self.internal_middleware = Bugsnag::MiddlewareStack.new
|
77
|
+
self.internal_middleware.use Bugsnag::Middleware::ExceptionMetaData
|
78
|
+
self.internal_middleware.use Bugsnag::Middleware::IgnoreErrorClass
|
79
|
+
self.internal_middleware.use Bugsnag::Middleware::SuggestionData
|
80
|
+
self.internal_middleware.use Bugsnag::Middleware::ClassifyError
|
78
81
|
|
79
82
|
self.middleware = Bugsnag::MiddlewareStack.new
|
80
83
|
self.middleware.use Bugsnag::Middleware::Callbacks
|
@@ -85,7 +88,7 @@ module Bugsnag
|
|
85
88
|
# notification endpoint.
|
86
89
|
#
|
87
90
|
def delivery_method
|
88
|
-
@delivery_method || @default_delivery_method ||
|
91
|
+
@delivery_method || @default_delivery_method || :thread_queue
|
89
92
|
end
|
90
93
|
|
91
94
|
##
|
@@ -104,13 +107,12 @@ module Bugsnag
|
|
104
107
|
@default_delivery_method = delivery_method
|
105
108
|
end
|
106
109
|
|
107
|
-
|
108
|
-
|
109
|
-
@mutex.synchronize { @ignore_classes.map! { |klass| klass.is_a?(Class) ? klass.name : klass } }
|
110
|
+
def should_notify_release_stage?
|
111
|
+
@release_stage.nil? || @notify_release_stages.nil? || @notify_release_stages.include?(@release_stage)
|
110
112
|
end
|
111
113
|
|
112
|
-
def
|
113
|
-
|
114
|
+
def valid_api_key?
|
115
|
+
!api_key.nil? && api_key =~ API_KEY_REGEX
|
114
116
|
end
|
115
117
|
|
116
118
|
def request_data
|
@@ -129,6 +131,20 @@ module Bugsnag
|
|
129
131
|
Thread.current[THREAD_LOCAL_NAME] = nil
|
130
132
|
end
|
131
133
|
|
134
|
+
def info(message)
|
135
|
+
logger.info(message)
|
136
|
+
end
|
137
|
+
|
138
|
+
# Warning logger
|
139
|
+
def warn(message)
|
140
|
+
logger.warn(message)
|
141
|
+
end
|
142
|
+
|
143
|
+
# Debug logger
|
144
|
+
def debug(message)
|
145
|
+
logger.debug(message)
|
146
|
+
end
|
147
|
+
|
132
148
|
private
|
133
149
|
|
134
150
|
def default_hostname
|