Issue Description
If sentry-sidekiq is required AFTER Sentry.init has been run, an exception is raised in ErrorHandler, as below (the Sentry.configuration.sidekiq field is nil).
This is because configuration.sidekiq is set in a 'post initialization callback', but once Sentry.init is run, the callbacks won't be run.
This is a really tough one to find and diagnose because it is an exception in an error handler, so of course trying to figure out what happened is very confusing, but obvious in hindsight.
Reproduction Steps
require sentry-ruby
Sentry.init
require sentry-sidekiq
- Provoke an error
- An exception is raised:
name:NoMethodError
message:undefined method `report_after_job_retries' for nil:NilClass
if Sentry.configuration.sidekiq.report_after_job_retries && retry_option.is_a?(Integer) && retry_option.positive?
Expected Behavior
Any one of:
post_initialization_callbacks are run immediately if Sentry is already initialized
- The lack of configuration is detected in
ErrorHandler, and a clear error is raised
- The issue with requiring-after-init is detected on import, and a clear error is raised
Actual Behavior
NoMethodError on nil is raised
Ruby Version
All (3.1 tested)
SDK Version
4.8.3
Integration and Its Version
Sidekiq, 4.8.3
Sentry Config
Just need to get Sentry configured in some way:
Sentry.init do |config|
config.dsn = 'https://examplePublicKey@o0.ingest.sentry.io/0'
end
Issue Description
If
sentry-sidekiqis required AFTERSentry.inithas been run, an exception is raised inErrorHandler, as below (theSentry.configuration.sidekiqfield is nil).This is because
configuration.sidekiqis set in a 'post initialization callback', but onceSentry.initis run, the callbacks won't be run.This is a really tough one to find and diagnose because it is an exception in an error handler, so of course trying to figure out what happened is very confusing, but obvious in hindsight.
Reproduction Steps
require sentry-rubySentry.initrequire sentry-sidekiqExpected Behavior
Any one of:
post_initialization_callbacksare run immediately if Sentry is already initializedErrorHandler, and a clear error is raisedActual Behavior
NoMethodError on nil is raised
Ruby Version
All (3.1 tested)
SDK Version
4.8.3
Integration and Its Version
Sidekiq, 4.8.3
Sentry Config
Just need to get Sentry configured in some way: