Skip to content

Commit

Permalink
Merge pull request #385 from bugsnag/kattrali/v6
Browse files Browse the repository at this point in the history
Release v6.0.0
  • Loading branch information
Cawllec authored Nov 9, 2017
2 parents 18cc6ab + dc48998 commit 9404f63
Show file tree
Hide file tree
Showing 198 changed files with 3,224 additions and 2,518 deletions.
5 changes: 0 additions & 5 deletions .document

This file was deleted.

44 changes: 33 additions & 11 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,38 @@
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 install bundler -v 1.12
- gem update --system
- bundle --version
- gem update --system 2.6.14
- gem --version
- gem install bundler -v 1.12
- bundle _1.12.0_ --version

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

script:
- bundle exec ./bin/rake spec

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
- stage: test
env: GEMSETS="test sidekiq"
rvm: 2.4.1
20 changes: 20 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,22 @@
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 'delayed_job' if RUBY_VERSION >= '2.2.2'
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
31 changes: 19 additions & 12 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,16 +1,5 @@
# encoding: utf-8

require 'rubygems'
require 'bundler'
require 'bundler/gem_tasks'
begin
Bundler.setup(:default, :development)
rescue Bundler::BundlerError => e
$stderr.puts e.message
$stderr.puts "Run `bundle install` to install missing gems"
exit e.status_code
end

require 'rdoc/task'
RDoc::Task.new do |rdoc|
version = File.exist?('VERSION') ? File.read('VERSION') : ""
Expand All @@ -24,6 +13,24 @@ end
# RSpec tasks
require 'rspec/core'
require "rspec/core/rake_task"
RSpec::Core::RakeTask.new(:spec)
RSpec::Core::RakeTask.new(:spec) do |task|
integration_exclusions = []
begin
require 'sidekiq/testing'
rescue LoadError
puts "Skipping sidekiq tests, missing dependencies"
integration_exclusions << 'sidekiq'
end
begin
require 'delayed_job'
rescue LoadError
puts "Skipping delayed_job tests, missing dependencies"
integration_exclusions << 'delayed_job'
end
if integration_exclusions.length > 0
pattern = integration_exclusions.join(',')
task.rspec_opts = " --exclude-pattern **/integrations/{#{pattern}}_spec.rb"
end
end

task :default => :spec
58 changes: 58 additions & 0 deletions UPGRADING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Upgrade Guide

## 5.x to 6.x

_Our Ruby library has gone through some major improvements and there are a few
changes required to use the new integrations_

#### Capistrano and deploys

Support for notifying Bugsnag of deployments has been separated into a separate
gem named `bugsnag-capistrano`. See the [integration
guide](https://docs.bugsnag.com/platforms/ruby/capistrano) for more information.


#### Configuration

* `Configuration.use_ssl` has been removed. Include the preferred protocol in `Configuration.endpoint` instead.
```diff
Bugsnag.configure do |config|
- config.use_ssl = true
- config.endpoint = 'myserver.example.com'
+ config.endpoint = 'https://myserver.example.com'
end
```
* `Configuration.ignore_classes` now no longer accepts strings. Use classes directly instead.
* `Configuration.delay_with_resque` has been removed
* `Configuration.vendor_paths` has been removed
* `Configuration.params_filters` has been renamed to `Configuration.meta_data_filters` to be clearer
* `Configuration.proxy_host` will now default to `ENV['http_proxy']` if set. It can still be manually set.

#### Notifying

* `notify` now only supports block syntax. Replace usage of the overrides hash with a block

```diff
- Bugsnag.notify(e, {severity: 'info'})
+ Bugsnag.notify(e) do |report|
+ report.severity = 'info'
+ end
```

* `Bugsnag.notify_or_ignore` and `Bugsnag.auto_notify` have been removed removed. Call `notify` directly instead.
* `after_notify_callbacks` has been removed
* `Bugsnag::Notification` has been renamed to `Bugsnag::Report`

#### Logging

* `config.debug` boolean has been removed. Set the logger level directly

```diff
+ require 'logger'

Bugsnag.configure do |config|
# .. set API key and other properties
- config.debug = true
+ config.logger.level = Logger::DEBUG
end
```
9 changes: 0 additions & 9 deletions bugsnag.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +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', '2.1.0'
s.add_development_dependency 'delayed_job'
s.add_development_dependency 'activesupport', '~> 4.2.10'
end
4 changes: 2 additions & 2 deletions example/padrino/Gemfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
source 'https://rubygems.org'

if ENV['INTEGRATION_LANGUAGE']
gem 'bugsnag', path: '../../../../'
gem 'bugsnag', path: '../../'
else
gem 'bugsnag'
end
Expand Down Expand Up @@ -38,7 +38,7 @@ gem 'riot', :group => 'test'
gem 'rack-test', :require => 'rack/test', :group => 'test'

# Padrino Stable Gem
gem 'padrino', '0.12.2'
gem 'padrino'

# Or Padrino Edge
# gem 'padrino', :github => 'padrino/padrino-framework'
Expand Down
97 changes: 27 additions & 70 deletions example/padrino/README.md
Original file line number Diff line number Diff line change
@@ -1,87 +1,44 @@
# Bugsnag Padrino demo

This Padrino application demonstrates how to use Bugsnag with Padrino. Before
testing it, open up the `config/boot.rb` file configure your API key inside
`Padrino.before_load`.
This Padrino application demonstrates how to use Bugsnag with Padrino.
Further details about integrating Bugsnag with Rack applications can be found [here.](https://docs.bugsnag.com/platforms/ruby/rack/)

```
Padrino.before_load do
Bugsnag.configure do |config|
config.api_key = '0a6f5add590596f93a8d601ea89af841'
end
end
Install dependencies

```shell
bundle install
```

In the same file activate the Bugsnag Rack middleware.
## Configuring Bugsnag and Padrino

```
Padrino.after_load do
Padrino.use Bugsnag::Rack
end
```
1. Set up the Padrino Bugsnag configuration in ```config/boot.rb``` in the `before_load` call according to the [available configuration options](https://docs.bugsnag.com/platforms/ruby/rack/configuration-options/):
```ruby
Padrino.before_load do
Bugsnag.configure do |config|
config.api_key = 'YOUR_API_KEY'
end
end
```

Open up `app/app.rb`, find two options and set them as follows: `raise_errors`
to `true` and `show_exceptions` to `false`. This enables automatic notifications
in the development environment. By default Padrino swallows exceptions from
Bugsnag (only in development, though).
2. Register the Rack middleware in ```config/boot.rb``` in the `after_load` call:
```ruby
Padrino.after_load do
Padrino.use Bugsnag::Rack
end
```

```
3. In `production` automatic notification of exceptions and errors will be enabled by default. If you want to enable notifications in `development`, open ```app/app.rb``` and set the following options:
```ruby
set :raise_errors, true
set :show_exceptions, false
```

If you would like to use custom error handlers, then you need to notify Bugsnag
explicitly.

```
error 500 do
Bugsnag.auto_notify($!)
erb :'errors/500'
end
```
## Running the example

Install dependencies.
Run the example using:

```
bundle install
```

Launch the Padrino application.

```
```shell
bundle exec padrino start
```

Next, open your project's dashboard on Bugsnag.

1. [crash](http://localhost:9292/crash)
<br/>
Crashes the application and sends a notification about the nature of the crash.
Basically, almost any unhandled exception sends a notification to Bugsnag. See
the line mentioning `get '/crash'` in `app/app.rb`.

1. [crash and use callbacks](http://localhost:9292/crash_with_callback)
<br/>
Before crashing, the application would append the Diagnostics tab with some
predefined information, attached by means of a callback. See the line mentioning
`get '/crash_with_callback'` in `app/app.rb`.

1. [notify](http://localhost:9292/notify)
<br/>
Bugsnag Ruby provides a way to send notifications on demand by means of
`Bugsnag.notify`. This API allows to send notifications manually, without
crashing your application. See the line mentioning `get '/notify'` in
`app/app.rb`.

1. [notify with meta data](http://localhost:9292/notify_meta)
<br/>
Same as `notify`, but also attaches meta data. The meta data is any additional
information you want to attach to an exception. In this artificial case
additional information with be sent and displayed in a new tab called
"Diagnostics". See the line mentioning `get '/notify_meta'` in `app/app.rb`.

1. [severity](http://localhost:9292/severity)
<br/>
Bugsnag supports three severities: 'error', 'warning' and 'info'. You can set
the severity by passing one of these objects as a string to '#notify'. See the
line mentioning `get '/severity'` in `app/app.rb`.
Once the server is running head to the default path for more information on Bugsnag logging examples.
30 changes: 15 additions & 15 deletions example/padrino/app/app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class App < Padrino::Application
fenced_code_blocks: true
}
renderer = Redcarpet::Markdown.new(Redcarpet::Render::HTML, opts)
renderer.render(File.read(File.expand_path('README.md')))
renderer.render(File.read(File.expand_path('app/templates/index.md')))
end

get '/crash' do
Expand All @@ -76,12 +76,12 @@ class App < Padrino::Application
end

get '/crash_with_callback' do
Bugsnag.before_notify_callbacks << proc { |notification|
Bugsnag.before_notify_callbacks << proc { |report|
new_tab = {
message: 'Padrino demo says: Everything is great',
code: 200
}
notification.add_tab(:diagnostics, new_tab)
report.add_tab(:diagnostics, new_tab)
}

msg = 'Bugsnag Padrino demo says: It crashed! But, due to the attached callback' +
Expand All @@ -98,31 +98,31 @@ class App < Padrino::Application
' for a new notification.'
end

get '/notify_meta' do
meta_data = {
:user => {
get '/notify_data' do
error = RuntimeError.new("Bugsnag Padrino demo says: False alarm, your application didn't crash")
Bugsnag.notify error do |report|
report.add_tab(:user, {
:username => "bob-hoskins",
:email => '[email protected]',
:registered_user => true
},

:diagnostics => {
})
report.add_tab(:diagnostics, {
:message => 'Padrino demo says: Everything is great',
:code => 200
}
}
error = RuntimeError.new("Bugsnag Padrino demo says: False alarm, your application didn't crash")
Bugsnag.notify(error, meta_data)
})
end

"Bugsnag Padrino demo says: It didn't crash! " +
'But still go check <a href="https://bugsnag.com">https://bugsnag.com</a>' +
' for a new notification. Check out the User tab for the meta data'
end

get '/severity' do
get '/notify_severity' do
msg = "Bugsnag Padrino demo says: Look at the circle on the right side. It's different"
error = RuntimeError.new(msg)
Bugsnag.notify(error, severity: 'info')
Bugsnag.notify error do |report|
report.severity = 'info'
end
msg
end
end
Expand Down
Loading

0 comments on commit 9404f63

Please sign in to comment.