Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V6 #320

Closed
wants to merge 94 commits into from
Closed

V6 #320

Show file tree
Hide file tree
Changes from 43 commits
Commits
Show all changes
94 commits
Select commit Hold shift + click to select a range
a1b9e42
Start thinking about new interface
snmaynard Aug 20, 2016
9f504dc
Progress
snmaynard Aug 20, 2016
2c8bae6
Progress
snmaynard Aug 20, 2016
94cea31
Merge in master and more progress on v5
snmaynard Aug 20, 2016
4e398c8
More progress
snmaynard Aug 20, 2016
44ff0b0
Specs are begining to come back together
snmaynard Aug 20, 2016
edf1a5a
Tests pass localy
snmaynard Aug 21, 2016
011e6cf
Silence logger
snmaynard Aug 21, 2016
96e6cd4
Logging
snmaynard Aug 21, 2016
713fad3
Not appropriate
snmaynard Aug 21, 2016
0e30d7a
Remove these
snmaynard Aug 21, 2016
7577dc5
Whitespace
snmaynard Aug 21, 2016
5144824
Report code coverage
kattrali Aug 11, 2017
5286521
Add spec filter
kattrali Aug 11, 2017
83ddab5
Skip old ruby when generating coverage specs
kattrali Aug 11, 2017
c955512
Test canceling reports, cleaning objects
kattrali Aug 11, 2017
6838fde
Test sidekiq integration
kattrali Aug 11, 2017
95b599d
Document how delivery works
kattrali Aug 11, 2017
03a1ebd
Constantize the default endpoint value
kattrali Aug 11, 2017
64f6dd1
Ensured default user_id set correctly in rack and rails3 middlewares …
Cawllec Aug 23, 2017
35eafcc
Modified test and travis system to check dependency separation
Cawllec Aug 24, 2017
c9d9b2b
Changed matrix makeup
Cawllec Aug 24, 2017
ca80cb2
Changed matrix makeup
Cawllec Aug 24, 2017
a8ef384
Ensured ruby-gems is up to date
Cawllec Aug 24, 2017
893de5a
Made more verbose
Cawllec Aug 24, 2017
fc011db
Ensured rvm versions correct and specified gem in specific cases
Cawllec Aug 24, 2017
8326a4b
Removed verbosity for easier reading
Cawllec Aug 24, 2017
de1b863
Ensured webmock installed correctly
Cawllec Aug 24, 2017
065a25b
Reporting environment options in build
Cawllec Aug 24, 2017
b228264
Seeing if issue tracked down
Cawllec Aug 25, 2017
95e68cb
Revert "Seeing if issue tracked down"
Cawllec Aug 25, 2017
0e5e903
Removed bundler caching
Cawllec Aug 25, 2017
38a12e7
Revert "Removed bundler caching"
Cawllec Aug 25, 2017
7c80ce9
Attempt to force bundler version
Cawllec Aug 25, 2017
fecaff0
Testing bundler without removal
Cawllec Aug 25, 2017
8373b1f
chore(ci): Switch gemset logic to be additive
kattrali Aug 25, 2017
770aff1
chore(ci): Update Ruby 2.1.8 in build matrix to 2.1.10
kattrali Aug 25, 2017
39d5e69
fix(ci): "Upgrade" bundler
kattrali Aug 25, 2017
7c02725
fix(spec): Skip test made irrelevant by Ruby 2.3.0 improvements
kattrali Aug 25, 2017
2678efc
fix(spec): Update JRuby test to match impl change in JRuby
kattrali Aug 25, 2017
f7502b7
fix(spec): Fix cleaner to be JSON+Ruby 1.9 compatible
kattrali Aug 25, 2017
b33760f
fix(ci): Fix bundler problems and tests on old rubies
kattrali Aug 26, 2017
f484dbf
chore(ci): Modified test system to check dep separation (#364)
kattrali Aug 26, 2017
403d8fa
Add an upgrade guide (#370)
kattrali Sep 20, 2017
ff8317a
Fixed incorrect path to bugsnag lib
Cawllec Aug 16, 2017
f6ca3bf
Ensured local bugsnag references correct library location
Cawllec Aug 16, 2017
6d8e174
Updated padrino example
Cawllec Sep 28, 2017
b8d421f
Removed favicon
Cawllec Sep 28, 2017
0427409
Updated to readme
Cawllec Sep 28, 2017
8534770
Updated rack example
Cawllec Sep 28, 2017
b5a4941
Updated rails server
Cawllec Sep 28, 2017
846a588
Fixed name
Cawllec Sep 28, 2017
4b48ab2
Updated error reasons
Cawllec Sep 28, 2017
05521af
Updated error reasons
Cawllec Sep 28, 2017
ad9959e
Updated resque example
Cawllec Sep 28, 2017
c258ac2
Removed API KEY
Cawllec Sep 29, 2017
42bd1e3
Remove ref
Cawllec Sep 29, 2017
7a12445
Updated resque/sidekiq examples
Cawllec Sep 29, 2017
7aaa01f
Updated sinatra example and sidekiq
Cawllec Sep 29, 2017
c994b16
Updated rails 4.2 example
Cawllec Sep 29, 2017
643ae3a
Track whether an error report is automatic (#368)
Cawllec Oct 2, 2017
ee93eab
Add 'did you mean' suggestions to metadata (#372)
Cawllec Oct 2, 2017
57331fe
Added rails 5.1 example
Cawllec Oct 3, 2017
cc9d267
Fixed incorrect path to bugsnag lib
Cawllec Aug 16, 2017
75e3b1b
Ensured local bugsnag references correct library location
Cawllec Aug 16, 2017
c0ee41b
Updated padrino example
Cawllec Sep 28, 2017
edb64da
Removed favicon
Cawllec Sep 28, 2017
e5d2d2f
Updated to readme
Cawllec Sep 28, 2017
1fd5ebb
Updated rack example
Cawllec Sep 28, 2017
0dd81d3
Updated rails server
Cawllec Sep 28, 2017
cc59789
Fixed name
Cawllec Sep 28, 2017
33b40ba
Updated error reasons
Cawllec Sep 28, 2017
425c947
Updated error reasons
Cawllec Sep 28, 2017
4d52ac5
Updated resque example
Cawllec Sep 28, 2017
4a926cc
Removed API KEY
Cawllec Sep 29, 2017
ab2e5c9
Remove ref
Cawllec Sep 29, 2017
0005ee0
Updated resque/sidekiq examples
Cawllec Sep 29, 2017
ad1a4aa
Updated sinatra example and sidekiq
Cawllec Sep 29, 2017
83834fa
Updated rails 4.2 example
Cawllec Sep 29, 2017
b1512fe
Added rails 5.1 example
Cawllec Oct 3, 2017
2342d8d
Merge branch 'v5-example-updates' of github.com:bugsnag/bugsnag-ruby …
Cawllec Oct 3, 2017
f61f948
Updated rails-42 example with delayed_job
Cawllec Oct 6, 2017
91d860a
Ensured correct commands mentioned
Cawllec Oct 6, 2017
54775b0
Ensured helper works correctly
Cawllec Oct 6, 2017
3f6e503
Enable setting proxy_host through environment variables (#379)
Cawllec Oct 6, 2017
a9a3b4e
Added warning if no valid key set
Cawllec Oct 11, 2017
a344910
Changed 'wrapper' to correct 'wrapped'
Cawllec Oct 11, 2017
64bf8c7
Added shoryken integration and example
Cawllec Oct 11, 2017
4ca6a9c
Added clearance middleware
Cawllec Oct 11, 2017
25b1942
Added default delivery method setting by integrations
Cawllec Oct 12, 2017
85db76c
Added que integration
Cawllec Oct 12, 2017
b587d42
Add changes from between v5 and v6 (#381)
kattrali Oct 12, 2017
38f2571
Update examples for v6 (#374)
kattrali Oct 12, 2017
35d540e
Updated version number
Cawllec Oct 26, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions .document

This file was deleted.

39 changes: 30 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,35 @@
sudo: false
language: ruby
cache: bundler
rvm:
- 2.3.0
- 2.2.4
- 2.1.8
- 2.0.0
- 1.9.3
- jruby-19mode

before_install:
- gem update --system 2.1.11
- gem install bundler -v 1.12
- gem update --system
- bundle --version
- gem --version

install:
- bundle _1.12.0_ install --with "$GEMSETS"

script:
- bundle _1.12.0_ exec rake

jobs:
include:
- stage: test
env: GEMSETS=test
rvm: jruby-19mode
- stage: test
env: GEMSETS=test
rvm: 1.9.3
- stage: test
env: GEMSETS=test
rvm: 2.0.0
- stage: test
env: GEMSETS=test
rvm: 2.1.10
- stage: test
env: GEMSETS="test sidekiq"
rvm: 2.2.4
- stage: test
env: GEMSETS="test sidekiq coverage"
rvm: 2.3.0
19 changes: 19 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,21 @@
source "https://rubygems.org"

group :test, optional: true do
gem 'rake', '~> 10.1.1'
gem 'rspec'
gem 'rdoc'
gem 'pry'
gem 'addressable', '~> 2.3.8'
gem 'webmock', RUBY_VERSION <= '1.9.3' ? '2.3.2': '>2.3.2'
end

group :coverage, optional: true do
gem 'simplecov'
gem 'coveralls'
end

group :sidekiq, optional: true do
gem 'sidekiq', '~> 5.0.4'
end

gemspec
12 changes: 10 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
require 'rubygems'
require 'bundler'
require 'bundler/gem_tasks'

begin
Bundler.setup(:default, :development)
Bundler.setup(:default)
rescue Bundler::BundlerError => e
$stderr.puts e.message
$stderr.puts "Run `bundle install` to install missing gems"
Expand All @@ -24,6 +25,13 @@ end
# RSpec tasks
require 'rspec/core'
require "rspec/core/rake_task"
RSpec::Core::RakeTask.new(:spec)
RSpec::Core::RakeTask.new(:spec) do |task|
begin
require 'sidekiq/testing'
rescue LoadError
puts "Skipping sidekiq tests, missing dependencies"
task.rspec_opts = "--exclude-pattern **/integrations/sidekiq_spec.rb"
end
end

task :default => :spec
7 changes: 0 additions & 7 deletions bugsnag.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,4 @@ Gem::Specification.new do |s|
]
s.require_paths = ["lib"]
s.required_ruby_version = '>= 1.9.2'

s.add_development_dependency 'rake', '~> 10.1.1'
s.add_development_dependency 'rspec'
s.add_development_dependency 'rdoc'
s.add_development_dependency 'pry'
s.add_development_dependency 'addressable', '~> 2.3.8'
s.add_development_dependency 'webmock'
end
5 changes: 4 additions & 1 deletion example/padrino/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ explicitly.

```
error 500 do
Bugsnag.auto_notify($!)
Bugsnag.notify($!) do |report|
report.severity = "error"
end

erb :'errors/500'
end
```
Expand Down
4 changes: 3 additions & 1 deletion example/sinatra/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ explicitly.

```
error 500 do
Bugsnag.auto_notify($!)
Bugsnag.notify($!) do |report|
report.severity = "error"
end
erb :'errors/500'
end
```
Expand Down
127 changes: 49 additions & 78 deletions lib/bugsnag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,16 @@
require "bugsnag/version"
require "bugsnag/configuration"
require "bugsnag/meta_data"
require "bugsnag/notification"
require "bugsnag/report"
require "bugsnag/cleaner"
require "bugsnag/helpers"
require "bugsnag/deploy"

require "bugsnag/delivery"
require "bugsnag/delivery/synchronous"
require "bugsnag/delivery/thread_queue"

require "bugsnag/rack"
require "bugsnag/railtie" if defined?(Rails::Railtie)
require "bugsnag/integrations/rack"
require "bugsnag/integrations/railtie" if defined?(Rails::Railtie)

require "bugsnag/middleware/rack_request"
require "bugsnag/middleware/warden_user"
Expand All @@ -23,81 +22,70 @@
require "bugsnag/middleware/sidekiq"
require "bugsnag/middleware/mailman"
require "bugsnag/middleware/rake"
require "bugsnag/middleware/callbacks"

module Bugsnag
LOG_PREFIX = "** [Bugsnag] "
LOCK = Mutex.new

class << self
# Configure the Bugsnag notifier application-wide settings.
def configure(config_hash=nil)
if config_hash
config_hash.each do |k,v|
configuration.send("#{k}=", v) rescue nil if configuration.respond_to?("#{k}=")
end
end

def configure
yield(configuration) if block_given?

# Use resque for asynchronous notification if required
require "bugsnag/delay/resque" if configuration.delay_with_resque && defined?(Resque)

# Log that we are ready to rock
@logged_ready = false unless defined?(@logged_ready)

if configuration.api_key && !@logged_ready
log "Bugsnag exception handler #{VERSION} ready"
@logged_ready = true
end
end

# Explicitly notify of an exception
def notify(exception, overrides=nil, request_data=nil, &block)
notification = Notification.new(exception, configuration, overrides, request_data)

yield(notification) if block_given?
def notify(exception, auto_notify=false, &block)
if auto_notify && !configuration.auto_notify
configuration.debug("Not notifying because auto_notify is disabled")
return
end

notification.deliver
notification
end
if !configuration.valid_api_key?
configuration.debug("Not notifying due to an invalid api_key")
return
end

# Notify of an exception unless it should be ignored
def notify_or_ignore(exception, overrides=nil, request_data=nil, &block)
notification = Notification.new(exception, configuration, overrides, request_data)
if !configuration.should_notify_release_stage?
configuration.debug("Not notifying due to notify_release_stages :#{configuration.notify_release_stages.inspect}")
return
end

yield(notification) if block_given?
report = Report.new(exception, configuration)

unless notification.ignore?
notification.deliver
notification
else
false
# If this is an auto_notify we yield the block before the any middleware is run
yield(report) if block_given? && auto_notify
if report.ignore?
configuration.debug("Not notifying #{report.exceptions.last[:errorClass]} due to ignore being signified in auto_notify block")
return
end
end

# Auto notify of an exception, called from rails and rack exception
# rescuers, unless auto notification is disabled, or we should ignore this
# error class
def auto_notify(exception, overrides=nil, request_data=nil, &block)
overrides ||= {}
overrides.merge!({:severity => "error"})
notify_or_ignore(exception, overrides, request_data, &block) if configuration.auto_notify
end
# Run internal middleware
configuration.internal_middleware.run(report)
if report.ignore?
configuration.debug("Not notifying #{report.exceptions.last[:errorClass]} due to ignore being signified in internal middlewares")
return
end

# Log wrapper
def log(message)
configuration.logger.info("#{LOG_PREFIX}#{message}")
end
# Run users middleware
configuration.middleware.run(report) do
if report.ignore?
configuration.debug("Not notifying #{report.exceptions.last[:errorClass]} due to ignore being signified in user provided middleware")
return
end

# Warning logger
def warn(message)
configuration.logger.warn("#{LOG_PREFIX}#{message}")
end
# If this is not an auto_notify then the block was provided by the user. This should be the last
# block that is run as it is the users "most specific" block.
yield(report) if block_given? && !auto_notify
if report.ignore?
configuration.debug("Not notifying #{report.exceptions.last[:errorClass]} due to ignore being signified in user provided block")
return
end

# Debug logger
def debug(message)
configuration.logger.info("#{LOG_PREFIX}#{message}") if configuration.debug
# Deliver
configuration.info("Notifying #{configuration.endpoint} of #{report.exceptions.last[:errorClass]}")
payload_string = ::JSON.dump(Bugsnag::Helpers.trim_if_needed(report.as_json))
configuration.debug("Payload: #{payload_string}")
Bugsnag::Delivery[configuration.delivery_method].deliver(configuration.endpoint, payload_string, configuration)
end
end

# Configuration getters
Expand All @@ -106,33 +94,16 @@ def configuration
@configuration || LOCK.synchronize { @configuration ||= Bugsnag::Configuration.new }
end

# Set "per-request" data, temporal data for use in bugsnag middleware
def set_request_data(key, value)
Bugsnag.configuration.set_request_data(key, value)
end

# Clear all "per-request" data, temporal data for use in bugsnag middleware
# This method should be called after each distinct request or session ends
# Eg. After completing a page request in a web app
def clear_request_data
Bugsnag.configuration.clear_request_data
end

# Allow access to "before notify" callbacks
def before_notify_callbacks
Bugsnag.configuration.request_data[:before_callbacks] ||= []
end

# Allow access to "after notify" callbacks
def after_notify_callbacks
Bugsnag.configuration.request_data[:after_callbacks] ||= []
end
end
end

[:resque, :sidekiq, :mailman, :delayed_job].each do |integration|
begin
require "bugsnag/#{integration}"
require "bugsnag/integrations/#{integration}"
rescue LoadError
end
end
7 changes: 0 additions & 7 deletions lib/bugsnag/capistrano.rb

This file was deleted.

32 changes: 0 additions & 32 deletions lib/bugsnag/capistrano2.rb

This file was deleted.

Loading