Skip to content

Commit

Permalink
Merge pull request #626 from bugsnag/sidekiq-delivery-method
Browse files Browse the repository at this point in the history
Use thread_queue delivery in Sidekiq
  • Loading branch information
imjoehaines committed Aug 13, 2020
2 parents 0afe6b6 + ce59ffc commit 2720148
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 4 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
Changelog
=========

## TBD

### Enhancements

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

## 6.16.0 (12 August 2020)

### Enhancements
Expand Down
1 change: 1 addition & 0 deletions features/fixtures/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,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
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
21 changes: 19 additions & 2 deletions features/sidekiq.feature
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ Scenario: An unhandled RuntimeError sends a report
And the event "severityReason.attributes.framework" 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 @@ -27,4 +28,20 @@ Scenario: A handled RuntimeError can be notified
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.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 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"
1 change: 0 additions & 1 deletion lib/bugsnag/integrations/sidekiq.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ class Sidekiq
def initialize
Bugsnag.configuration.internal_middleware.use(Bugsnag::Middleware::Sidekiq)
Bugsnag.configuration.detected_app_type = "sidekiq"
Bugsnag.configuration.default_delivery_method = :synchronous
Bugsnag.configuration.runtime_versions["sidekiq"] = ::Sidekiq::VERSION
end

Expand Down

0 comments on commit 2720148

Please sign in to comment.