Skip to content

Commit

Permalink
Merge branch 'master' into cawllec/sidekiq-3-handler
Browse files Browse the repository at this point in the history
  • Loading branch information
Cawllec authored Apr 25, 2018
2 parents 0f5f8d8 + 2a61e9b commit e794cee
Show file tree
Hide file tree
Showing 26 changed files with 693 additions and 69 deletions.
15 changes: 7 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,10 @@ jobs:
rvm: 2.4.1
script: bundle exec rake rdoc
if: tag =~ ^v[1-9]

deploy:
provider: pages
local_dir: rdoc # only include the contents of the generated docs dir
skip_cleanup: true
github_token: $GITHUB_TOKEN # set in travis-ci dashboard
on:
tags: true # only deploy when tag is applied to commit
deploy:
provider: pages
local_dir: rdoc # only include the contents of the generated docs dir
skip_cleanup: true
github_token: $GITHUB_TOKEN # set in travis-ci dashboard
on:
tags: true # only deploy when tag is applied to commit
35 changes: 35 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,41 @@
Changelog
=========

## 6.7.2 (24 Apr 2018)

### Fixes

* (Notify) Handle `notify` calls with `nil` arguments correctly
| [#439](https://github.com/bugsnag/bugsnag-ruby/pull/439)

## 6.7.1 (11 Apr 2018)

### Fixes

* (Rails) Log missing key warning after initialization completes, avoiding
incorrectly logging a warning that the API key is missing
| [#444](https://github.com/bugsnag/bugsnag-ruby/pull/444)

## 6.7.0 (05 Apr 2018)

### Enhancements

* Support HTTP proxy from `http_proxy` and `https_proxy` environment variables
| [#424](https://github.com/bugsnag/bugsnag-ruby/pull/424)
| [#437](https://github.com/bugsnag/bugsnag-ruby/pull/437)
| [Bill Kirtley](https://github.com/cluesque)

* Add option to disable auto-configuration
| [#419](https://github.com/bugsnag/bugsnag-ruby/pull/419)

* Add `warden.user.rack` data to default filters
| [#436](https://github.com/bugsnag/bugsnag-ruby/pull/436)

### Fixes

* Ensure logged messages include Bugsnag progname
| [#443](https://github.com/bugsnag/bugsnag-ruby/pull/443)

## 6.6.4 (14 Feb 2018)

### Fixes
Expand Down
2 changes: 1 addition & 1 deletion UPGRADING.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ guide](https://docs.bugsnag.com/api/deploy-tracking/capistrano/) for more inform
+ end
```

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

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6.6.4
6.7.2
2 changes: 1 addition & 1 deletion bugsnag.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Gem::Specification.new do |s|

s.description = "Ruby notifier for bugsnag.com"
s.summary = "Ruby notifier for bugsnag.com"
s.homepage = "http://github.com/bugsnag/bugsnag-ruby"
s.homepage = "https://github.com/bugsnag/bugsnag-ruby"
s.licenses = ["MIT"]

s.files = `git ls-files`.split("\n").reject {|file| file.start_with? "example/"}
Expand Down
56 changes: 43 additions & 13 deletions issue_template.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,48 @@
### Expected behavior
*[Insert details on expected behaviour]*
### Description
<!-- A quick description of what you're trying to accomplish -->

### Observed behavior
*[Insert details on observed behaviour]*
### Issue
<!--
What went wrong? (If this issue is a general question or a proposed change,
feel free to delete this and subsequent sections.
-->

### Steps to reproduce
*[Insert reproduction steps (if known)]*
### Environment

### Version
*[Insert version information]*
Library versions:

### Additional information
*[Insert any additional information]*
<!--
Paste the output of this command into the code block below:
bundle list | grep -E "(bugsnag|rails|sidekiq|que|sinatra|resque|shoryuken|mailman|delayed_job)"
-->
```
#### Can't comment on Issues?
Some users have been unable to comment on Github issues when an [adblocker extension is enabled](https://docs.bugsnag.com/platforms/browsers/faq/#is-bugsnag-blocked-by-ad-blockers).
We recommend temporarily disabling the extension, or if that fails, contacting support@bugsnag.com.
```

- OS / OS version:
- debug mode or production?:

<!--
Below are a few approaches you might take to communicate the issue, in
descending order of awesomeness. Please choose one and feel free to delete
the others from this template.
-->
### Example Repo

- [ ] Create a minimal repository that can reproduce the issue after running
`bundle install` and `rackup` (or `rails server`, or `ruby some-script.rb`,
etc)
- [ ] Link to it here:

### Example code snippet

```ruby
require 'bugsnag'

# (Insert code sample to reproduce the problem)
```

<!-- Error messages, if any -->
```
```
91 changes: 60 additions & 31 deletions lib/bugsnag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
require "bugsnag/delivery/synchronous"
require "bugsnag/delivery/thread_queue"

# Rack is not bundled with the other integrations
# as it doesn't auto-configure when loaded
require "bugsnag/integrations/rack"

require "bugsnag/middleware/rack_request"
Expand All @@ -28,20 +30,19 @@

module Bugsnag
LOCK = Mutex.new
INTEGRATIONS = [:resque, :sidekiq, :mailman, :delayed_job, :shoryuken, :que]

NIL_EXCEPTION_DESCRIPTION = "'nil' was notified as an exception"

class << self
##
# Configure the Bugsnag notifier application-wide settings.
#
# Yields a configuration object to use to set application settings.
def configure
def configure(validate_api_key=true)
yield(configuration) if block_given?

@key_warning = false unless defined?(@key_warning)
if !configuration.valid_api_key? && !@key_warning
configuration.warn("No valid API key has been set, notifications will not be sent")
@key_warning = true
end
check_key_valid if validate_api_key
end

##
Expand All @@ -54,25 +55,9 @@ def notify(exception, auto_notify=false, &block)
auto_notify = false
end

if !configuration.auto_notify && auto_notify
configuration.debug("Not notifying because auto_notify is disabled")
return
end

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

if !configuration.should_notify_release_stage?
configuration.debug("Not notifying due to notify_release_stages :#{configuration.notify_release_stages.inspect}")
return
end
return unless deliver_notification?(exception, auto_notify)

if exception.respond_to?(:skip_bugsnag) && exception.skip_bugsnag
configuration.debug("Not notifying due to skip_bugsnag flag")
return
end
exception = NIL_EXCEPTION_DESCRIPTION if exception.nil?

report = Report.new(exception, configuration, auto_notify)

Expand Down Expand Up @@ -155,13 +140,57 @@ def start_session
def before_notify_callbacks
Bugsnag.configuration.request_data[:before_callbacks] ||= []
end
end
end

require "bugsnag/integrations/railtie" if defined?(Rails::Railtie)
[:resque, :sidekiq, :mailman, :delayed_job, :shoryuken, :que].each do |integration|
begin
require "bugsnag/integrations/#{integration}"
rescue LoadError
# Attempts to load all integrations through auto-discovery
def load_integrations
require "bugsnag/integrations/railtie" if defined?(Rails::Railtie)
INTEGRATIONS.each do |integration|
begin
require "bugsnag/integrations/#{integration}"
rescue LoadError
end
end
end

# Load a specific integration
def load_integration(integration)
integration = :railtie if integration == :rails
if INTEGRATIONS.include?(integration) || integration == :railtie
require "bugsnag/integrations/#{integration}"
else
configuration.debug("Integration #{integration} is not currently supported")
end
end

private

def deliver_notification?(exception, auto_notify)
reason = abort_reason(exception, auto_notify)
configuration.debug(reason) unless reason.nil?
reason.nil?
end

def abort_reason(exception, auto_notify)
if !configuration.auto_notify && auto_notify
"Not notifying because auto_notify is disabled"
elsif !configuration.valid_api_key?
"Not notifying due to an invalid api_key"
elsif !configuration.should_notify_release_stage?
"Not notifying due to notify_release_stages :#{configuration.notify_release_stages.inspect}"
elsif exception.respond_to?(:skip_bugsnag) && exception.skip_bugsnag
"Not notifying due to skip_bugsnag flag"
end
end

# Check if the API key is valid and warn (once) if it is not
def check_key_valid
@key_warning = false unless defined?(@key_warning)
if !configuration.valid_api_key? && !@key_warning
configuration.warn("No valid API key has been set, notifications will not be sent")
@key_warning = true
end
end
end
end

Bugsnag.load_integrations unless ENV["BUGSNAG_DISABLE_AUTOCONFIGURE"]
31 changes: 20 additions & 11 deletions lib/bugsnag/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class Configuration
/cookie/i,
/password/i,
/secret/i,
/warden\.user\.([^.]+)\.key/,
"rack.request.form_vars"
].freeze

Expand Down Expand Up @@ -75,20 +76,16 @@ def initialize
# Read the API key from the environment
self.api_key = ENV["BUGSNAG_API_KEY"]

# Read NET::HTTP proxy environment variable
if ENV["http_proxy"]
uri = URI.parse(ENV["http_proxy"])
self.proxy_host = uri.host
self.proxy_port = uri.port
self.proxy_user = uri.user
self.proxy_password = uri.password
# Read NET::HTTP proxy environment variables
if (proxy_uri = ENV["https_proxy"] || ENV['http_proxy'])
parse_proxy(proxy_uri)
end

# Set up logging
self.logger = Logger.new(STDOUT)
self.logger.level = Logger::INFO
self.logger.formatter = proc do |severity, datetime, progname, msg|
"** [Bugsnag] #{datetime}: #{msg}\n"
"** #{progname} #{datetime}: #{msg}\n"
end

# Configure the bugsnag middleware stack
Expand Down Expand Up @@ -168,23 +165,35 @@ def clear_request_data
##
# Logs an info level message
def info(message)
logger.info(message)
logger.info(PROG_NAME) { message }
end

##
# Logs a warning level message
def warn(message)
logger.warn(message)
logger.warn(PROG_NAME) { message }
end

##
# Logs a debug level message
def debug(message)
logger.debug(message)
logger.debug(PROG_NAME) { message }
end

##
# Parses and sets proxy from a uri
def parse_proxy(uri)
proxy = URI.parse(uri)
self.proxy_host = proxy.host
self.proxy_port = proxy.port
self.proxy_user = proxy.user
self.proxy_password = proxy.password
end

private

PROG_NAME = "[Bugsnag]"

def default_hostname
# Send the heroku dyno name instead of hostname if available
ENV["DYNO"] || Socket.gethostname;
Expand Down
4 changes: 3 additions & 1 deletion lib/bugsnag/integrations/railtie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ class Railtie < Rails::Railtie

config.before_initialize do
# Configure bugsnag rails defaults
Bugsnag.configure do |config|
# Skipping API key validation as the key may be set later in an
# initializer. If not, the key will be validated in after_initialize.
Bugsnag.configure(false) do |config|
config.logger = ::Rails.logger
config.release_stage = ENV["BUGSNAG_RELEASE_STAGE"] || ::Rails.env.to_s
config.project_root = ::Rails.root.to_s
Expand Down
2 changes: 1 addition & 1 deletion lib/bugsnag/report.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module Bugsnag
class Report
NOTIFIER_NAME = "Ruby Bugsnag Notifier"
NOTIFIER_VERSION = Bugsnag::VERSION
NOTIFIER_URL = "http://www.bugsnag.com"
NOTIFIER_URL = "https://www.bugsnag.com"

UNHANDLED_EXCEPTION = "unhandledException"
UNHANDLED_EXCEPTION_MIDDLEWARE = "unhandledExceptionMiddleware"
Expand Down
Loading

0 comments on commit e794cee

Please sign in to comment.