diff --git a/CHANGELOG.md b/CHANGELOG.md index 3713c9523..a6b729a9f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/features/fixtures/docker-compose.yml b/features/fixtures/docker-compose.yml index 0357d5fb5..b5815d43e 100644 --- a/features/fixtures/docker-compose.yml +++ b/features/fixtures/docker-compose.yml @@ -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 diff --git a/features/fixtures/sidekiq/app/app.rb b/features/fixtures/sidekiq/app/app.rb index 44e9b50fe..436325940 100644 --- a/features/fixtures/sidekiq/app/app.rb +++ b/features/fixtures/sidekiq/app/app.rb @@ -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| @@ -32,4 +43,4 @@ class UnhandledError def perform raise RuntimeError.new("Unhandled") end -end \ No newline at end of file +end diff --git a/features/sidekiq.feature b/features/sidekiq.feature index a7842fa0c..499520170 100644 --- a/features/sidekiq.feature +++ b/features/sidekiq.feature @@ -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" @@ -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 \ No newline at end of file + 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" diff --git a/lib/bugsnag/integrations/sidekiq.rb b/lib/bugsnag/integrations/sidekiq.rb index b2590e5b1..3fcb4c2bc 100644 --- a/lib/bugsnag/integrations/sidekiq.rb +++ b/lib/bugsnag/integrations/sidekiq.rb @@ -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