Skip to content

Commit

Permalink
Release v6.17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
imjoehaines authored Aug 27, 2020
2 parents 5e264fe + e9e6b7c commit fe82dca
Show file tree
Hide file tree
Showing 19 changed files with 365 additions and 91 deletions.
27 changes: 0 additions & 27 deletions .rdoc_options

This file was deleted.

11 changes: 11 additions & 0 deletions .yardopts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--charset UTF-8
--fail-on-warning
--hide-api private
--no-private
--protected
--title "bugsnag-ruby API Documentation"
lib/**/*.rb
-
README.md
CONTRIBUTING.md
CHANGELOG.md
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
Changelog
=========

## 6.17.0 (27 August 2020)

### Enhancements

* Sidekiq now uses `thread_queue` delivery by default
| [#626](https://github.com/bugsnag/bugsnag-ruby/pull/626)

* Rescue now uses `thread_queue` delivery when `at_exit` hooks are enabled
| [#629](https://github.com/bugsnag/bugsnag-ruby/pull/629)

## 6.16.0 (12 August 2020)

### Enhancements
Expand Down
20 changes: 13 additions & 7 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,29 @@ Thank you!

### Getting started

- [Fork](https://help.github.com/articles/fork-a-repo) the [library on github](https://github.com/bugsnag/bugsnag-ruby)
- Commit and push until you are happy with your contribution
* [Fork](https://help.github.com/articles/fork-a-repo) the [library on github](https://github.com/bugsnag/bugsnag-ruby)
* Commit and push until you are happy with your contribution

### Polish

- Run the tests with and make sure they all pass

* Run the tests with and make sure they all pass
```
bundle exec rake spec
```
- Further information on installing and running the tests can be found in [the testing guide](TESTING.md)
* Further information on installing and running the tests can be found in [the testing guide](TESTING.md)
### Document
### Ship it!
* Write API docs for your contributions using [YARD](https://yardoc.org/)
* Generate the API documentation locally
```
bundle exec rake yard
```
* Review your changes by opening `doc/index.html`
- [Make a pull request](https://help.github.com/articles/using-pull-requests)
### Ship it!
* [Make a pull request](https://help.github.com/articles/using-pull-requests)
## How to release
Expand Down
6 changes: 1 addition & 5 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ group :test, optional: true do
gem 'rake', ruby_version <= Gem::Version.new('1.9.3') ? '~> 11.3.0' : '~> 12.3.0'
gem 'rspec'
gem 'rspec-mocks'
gem 'rdoc', ruby_version < Gem::Version.new('2.2.0') ? '4.3.0' : '~> 5.1.0'
gem 'yard', '~> 0.9.25'
gem 'pry'
gem 'addressable', '~> 2.3.8'
if ruby_version >= Gem::Version.new('2.2.2')
Expand Down Expand Up @@ -43,8 +43,4 @@ group :sidekiq, optional: true do
gem 'rack', ruby_version < Gem::Version.new('2.3.0') ? '< 2.2.0' : '~> 2.2'
end

group :doc, optional: true do
gem 'hanna-nouveau'
end

gemspec
25 changes: 13 additions & 12 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,37 +1,38 @@
# encoding: utf-8

require 'rdoc/task'
RDoc::Task.new do |rdoc|
rdoc.rdoc_dir = 'rdoc'
rdoc.rdoc_files.include('README.md')
rdoc.rdoc_files.include('CONTRIBUTING.md')
rdoc.rdoc_files.include('CHANGELOG.md')
rdoc.rdoc_files.include('lib/**/*.rb')
rdoc.options.push '-f', 'hanna'
rdoc.markup = 'markdown'
require 'yard'
require 'rspec/core'
require "rspec/core/rake_task"

# Yard task (rake yard)
YARD::Rake::YardocTask.new do |task|
version = File.read("VERSION").strip

task.options += ["--title", "bugsnag-ruby v#{version} API Documentation"]
end

# RSpec tasks
require 'rspec/core'
require "rspec/core/rake_task"
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
task default: :spec
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6.16.0
6.17.0
2 changes: 1 addition & 1 deletion bugsnag.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Gem::Specification.new do |s|
s.homepage = "https://github.com/bugsnag/bugsnag-ruby"
s.licenses = ["MIT"]

s.files = `git ls-files -z lib bugsnag.gemspec VERSION`.split("\x0")
s.files = `git ls-files -z lib bugsnag.gemspec VERSION .yardopts`.split("\x0")
s.extra_rdoc_files = [
"LICENSE.txt",
"README.md",
Expand Down
2 changes: 1 addition & 1 deletion dockerfiles/Dockerfile.ruby-maze-runner
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ COPY bugsnag.gemspec Gemfile VERSION ./

RUN bundle install

COPY CHANGELOG.md CONTRIBUTING.md TESTING.md LICENSE.txt Rakefile README.md UPGRADING.md .gitignore .rdoc_options .rspec .rubocop.yml .rubocop_todo.yml docker-compose.yml ./
COPY CHANGELOG.md CONTRIBUTING.md TESTING.md LICENSE.txt Rakefile README.md UPGRADING.md .gitignore .rspec .rubocop.yml .rubocop_todo.yml .yardopts docker-compose.yml ./
COPY .buildkite ./.buildkite
COPY .git ./.git
COPY .github ./.github
Expand Down
2 changes: 2 additions & 0 deletions features/fixtures/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ services:
- DB_PASSWORD=test_password
- DB_HOST=postgres
- REDIS_URL=redis://redis:6379
- RUN_AT_EXIT_HOOKS
restart: "no"

sidekiq:
Expand All @@ -275,6 +276,7 @@ services:
- BUGSNAG_APP_VERSION
- BUGSNAG_AUTO_CAPTURE_SESSIONS
- BUGSNAG_AUTO_NOTIFY
- BUGSNAG_DELIVERY_METHOD
- BUGSNAG_ENDPOINT
- BUGSNAG_IGNORE_CLASS
- BUGSNAG_IGNORE_MESSAGE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,10 @@
config.api_key = ENV['BUGSNAG_API_KEY']
config.endpoint = ENV['BUGSNAG_ENDPOINT']
config.session_endpoint = ENV['BUGSNAG_ENDPOINT']

config.add_on_error(proc do |report|
report.add_tab(:config, {
delivery_method: config.delivery_method.to_s,
})
end)
end
13 changes: 12 additions & 1 deletion features/fixtures/sidekiq/app/app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,17 @@
conf.api_key = ENV['BUGSNAG_API_KEY']
puts "Configuring `endpoint` to #{ENV['BUGSNAG_ENDPOINT']}"
conf.endpoint = ENV['BUGSNAG_ENDPOINT']

if ENV.include?('BUGSNAG_DELIVERY_METHOD')
puts "Configuring `delivery_method` to #{ENV['BUGSNAG_DELIVERY_METHOD']}"
conf.delivery_method = ENV['BUGSNAG_DELIVERY_METHOD'].to_sym
end

conf.add_on_error(proc do |report|
report.add_tab(:config, {
delivery_method: conf.delivery_method.to_s
})
end)
end

Sidekiq.configure_client do |config|
Expand All @@ -32,4 +43,4 @@ class UnhandledError
def perform
raise RuntimeError.new("Unhandled")
end
end
end
24 changes: 23 additions & 1 deletion features/rails_features/integrations.feature
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ Scenario: Rake
And the event "metaData.rake_task.arguments" is null

@rails_integrations
Scenario: Resque
Scenario: Resque (no on_exit hooks)
When I run "bundle exec rake resque:work" in the rails app
And I run "Resque.enqueue(ResqueWorker)" with the rails runner
And I wait to receive a request
Expand All @@ -82,6 +82,28 @@ Scenario: Resque
And the event "severityReason.attributes.framework" equals "Resque"
And the event "app.type" equals "resque"
And the exception "errorClass" equals "RuntimeError"
And the event "metaData.config.delivery_method" equals "synchronous"
And the event "metaData.context" equals "ResqueWorker@crash"
And the event "metaData.payload.class" equals "ResqueWorker"
And the event "metaData.rake_task.name" equals "resque:work"
And the event "metaData.rake_task.description" equals "Start a Resque worker"
And the event "metaData.rake_task.arguments" is null

@rails_integrations
Scenario: Resque (with on_exit hooks)
Given I set environment variable "RUN_AT_EXIT_HOOKS" to "1"
When I run "bundle exec rake resque:work" in the rails app
And I run "Resque.enqueue(ResqueWorker)" with the rails runner
And I wait to receive a request
Then the request is valid for the error reporting API version "4.0" for the "Ruby Bugsnag Notifier"
And the event "unhandled" is true
And the event "context" equals "ResqueWorker@crash"
And the event "severity" equals "error"
And the event "severityReason.type" equals "unhandledExceptionMiddleware"
And the event "severityReason.attributes.framework" equals "Resque"
And the event "app.type" equals "resque"
And the exception "errorClass" equals "RuntimeError"
And the event "metaData.config.delivery_method" equals "thread_queue"
And the event "metaData.context" equals "ResqueWorker@crash"
And the event "metaData.payload.class" equals "ResqueWorker"
And the event "metaData.rake_task.name" equals "resque:work"
Expand Down
20 changes: 19 additions & 1 deletion features/sidekiq.feature
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ Scenario: An unhandled RuntimeError sends a report
And the event "app.type" equals "sidekiq"
And the exception "errorClass" equals "RuntimeError"
And the "file" of stack frame 0 equals "/app/app.rb"
And the "lineNumber" of stack frame 0 equals 33
And the "lineNumber" of stack frame 0 equals 44
And the payload field "events.0.metaData.sidekiq" matches the appropriate Sidekiq unhandled payload
And the event "metaData.sidekiq.msg.created_at" is a parsable timestamp in seconds
And the event "metaData.sidekiq.msg.enqueued_at" is a parsable timestamp in seconds
And the event "metaData.config.delivery_method" equals "thread_queue"

Scenario: A handled RuntimeError can be notified
Given I run the service "sidekiq" with the command "bundle exec rake sidekiq_tests:handled_error"
Expand All @@ -30,3 +31,20 @@ Scenario: A handled RuntimeError can be notified
And the payload field "events.0.metaData.sidekiq" matches the appropriate Sidekiq handled payload
And the event "metaData.sidekiq.msg.created_at" is a parsable timestamp in seconds
And the event "metaData.sidekiq.msg.enqueued_at" is a parsable timestamp in seconds
And the event "metaData.config.delivery_method" equals "thread_queue"

Scenario: Synchronous delivery can be used
Given I set environment variable "BUGSNAG_DELIVERY_METHOD" to "synchronous"
And I run the service "sidekiq" with the command "bundle exec rake sidekiq_tests:handled_error"
And I wait to receive a request
Then the request is valid for the error reporting API version "4.0" for the "Ruby Bugsnag Notifier"
And the event "unhandled" is false
And the event "context" equals "HandledError@default"
And the event "severity" equals "warning"
And the event "severityReason.type" equals "handledException"
And the event "app.type" equals "sidekiq"
And the exception "errorClass" equals "RuntimeError"
And the payload field "events.0.metaData.sidekiq" matches the appropriate Sidekiq handled payload
And the event "metaData.sidekiq.msg.created_at" is a parsable timestamp in seconds
And the event "metaData.sidekiq.msg.enqueued_at" is a parsable timestamp in seconds
And the event "metaData.config.delivery_method" equals "synchronous"
32 changes: 26 additions & 6 deletions lib/bugsnag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ class << self
##
# Configure the Bugsnag notifier application-wide settings.
#
# Yields a configuration object to use to set application settings.
# Yields a {Configuration} object to use to set application settings.
#
# @yieldparam configuration [Configuration]
# @return [void]
def configure(validate_api_key=true)
yield(configuration) if block_given?

Expand Down Expand Up @@ -125,7 +128,9 @@ def notify(exception, auto_notify=false, &block)
end

##
# Registers an at_exit function to automatically catch errors on exit
# Registers an at_exit function to automatically catch errors on exit.
#
# @return [void]
def register_at_exit
return if at_exit_handler_installed?
@exit_handler_added = true
Expand All @@ -142,14 +147,19 @@ def register_at_exit
end

##
# Checks if an at_exit handler has been added
# Checks if an at_exit handler has been added.
#
# The {Bugsnag#configure} method will add this automatically, but it can be
# added manually using {Bugsnag#register_at_exit}.
#
# @return [Boolean]
def at_exit_handler_installed?
@exit_handler_added ||= false
end

# Configuration getters
##
# Returns the client's Configuration object, or creates one if not yet created.
#
# @return [Configuration]
def configuration
@configuration = nil unless defined?(@configuration)
Expand All @@ -158,6 +168,8 @@ def configuration

##
# Returns the client's SessionTracker object, or creates one if not yet created.
#
# @return [SessionTracker]
def session_tracker
@session_tracker = nil unless defined?(@session_tracker)
@session_tracker || LOCK.synchronize { @session_tracker ||= Bugsnag::SessionTracker.new}
Expand All @@ -181,7 +193,10 @@ def before_notify_callbacks
Bugsnag.configuration.request_data[:before_callbacks] ||= []
end

# Attempts to load all integrations through auto-discovery
##
# Attempts to load all integrations through auto-discovery.
#
# @return [void]
def load_integrations
require "bugsnag/integrations/railtie" if defined?(Rails::Railtie)
INTEGRATIONS.each do |integration|
Expand All @@ -192,7 +207,11 @@ def load_integrations
end
end

# Load a specific integration
##
# Load a specific integration.
#
# @param integration [Symbol] One of the integrations in {INTEGRATIONS}
# @return [void]
def load_integration(integration)
integration = :railtie if integration == :rails
if INTEGRATIONS.include?(integration) || integration == :railtie
Expand All @@ -209,6 +228,7 @@ def load_integration(integration)
# @param meta_data [Hash] String, Numeric, or Boolean meta data to attach
# @param type [String] the breadcrumb type, from Bugsnag::Breadcrumbs::VALID_BREADCRUMB_TYPES
# @param auto [Symbol] set to :auto if the breadcrumb is automatically created
# @return [void]
def leave_breadcrumb(name, meta_data={}, type=Bugsnag::Breadcrumbs::MANUAL_BREADCRUMB_TYPE, auto=:manual)
breadcrumb = Bugsnag::Breadcrumbs::Breadcrumb.new(name, type, meta_data, auto)
validator = Bugsnag::Breadcrumbs::Validator.new(configuration)
Expand Down
Loading

0 comments on commit fe82dca

Please sign in to comment.