diff --git a/CHANGELOG.md b/CHANGELOG.md index 083f2c569..9c983ca60 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ - Add support for ActiveRecord binds in the log events ([#2761](https://github.com/getsentry/sentry-ruby/pull/2761)) +### Bug Fixes + +- Guard log subscribers with initialized check ([#2765](https://github.com/getsentry/sentry-ruby/pull/2765)) + ## 6.0.0 ### Breaking Changes diff --git a/sentry-rails/lib/sentry/rails/log_subscribers/action_controller_subscriber.rb b/sentry-rails/lib/sentry/rails/log_subscribers/action_controller_subscriber.rb index 94a804cf8..4b317e564 100644 --- a/sentry-rails/lib/sentry/rails/log_subscribers/action_controller_subscriber.rb +++ b/sentry-rails/lib/sentry/rails/log_subscribers/action_controller_subscriber.rb @@ -27,6 +27,8 @@ class ActionControllerSubscriber < Sentry::Rails::LogSubscriber # # @param event [ActiveSupport::Notifications::Event] The controller action event def process_action(event) + return unless Sentry.initialized? + payload = event.payload controller = payload[:controller] diff --git a/sentry-rails/lib/sentry/rails/log_subscribers/action_mailer_subscriber.rb b/sentry-rails/lib/sentry/rails/log_subscribers/action_mailer_subscriber.rb index 63f16e41f..2d8237fb7 100644 --- a/sentry-rails/lib/sentry/rails/log_subscribers/action_mailer_subscriber.rb +++ b/sentry-rails/lib/sentry/rails/log_subscribers/action_mailer_subscriber.rb @@ -26,6 +26,8 @@ class ActionMailerSubscriber < Sentry::Rails::LogSubscriber # # @param event [ActiveSupport::Notifications::Event] The email delivery event def deliver(event) + return unless Sentry.initialized? + payload = event.payload mailer = payload[:mailer] @@ -57,6 +59,8 @@ def deliver(event) # # @param event [ActiveSupport::Notifications::Event] The email processing event def process(event) + return unless Sentry.initialized? + payload = event.payload mailer = payload[:mailer] diff --git a/sentry-rails/lib/sentry/rails/log_subscribers/active_job_subscriber.rb b/sentry-rails/lib/sentry/rails/log_subscribers/active_job_subscriber.rb index e0181ee8a..da3353894 100644 --- a/sentry-rails/lib/sentry/rails/log_subscribers/active_job_subscriber.rb +++ b/sentry-rails/lib/sentry/rails/log_subscribers/active_job_subscriber.rb @@ -26,6 +26,8 @@ class ActiveJobSubscriber < Sentry::Rails::LogSubscriber # # @param event [ActiveSupport::Notifications::Event] The job performance event def perform(event) + return unless Sentry.initialized? + job = event.payload[:job] duration = duration_ms(event) @@ -63,6 +65,8 @@ def perform(event) # # @param event [ActiveSupport::Notifications::Event] The job enqueue event def enqueue(event) + return unless Sentry.initialized? + job = event.payload[:job] attributes = { @@ -89,6 +93,8 @@ def enqueue(event) end def retry_stopped(event) + return unless Sentry.initialized? + job = event.payload[:job] error = event.payload[:error] @@ -111,6 +117,8 @@ def retry_stopped(event) end def discard(event) + return unless Sentry.initialized? + job = event.payload[:job] error = event.payload[:error] diff --git a/sentry-rails/lib/sentry/rails/log_subscribers/active_record_subscriber.rb b/sentry-rails/lib/sentry/rails/log_subscribers/active_record_subscriber.rb index 72f563356..e6a2aeb9e 100644 --- a/sentry-rails/lib/sentry/rails/log_subscribers/active_record_subscriber.rb +++ b/sentry-rails/lib/sentry/rails/log_subscribers/active_record_subscriber.rb @@ -29,6 +29,7 @@ class ActiveRecordSubscriber < Sentry::Rails::LogSubscriber # # @param event [ActiveSupport::Notifications::Event] The SQL event def sql(event) + return unless Sentry.initialized? return if EXCLUDED_NAMES.include?(event.payload[:name]) sql = event.payload[:sql]