Skip to content

Commit a1680da

Browse files
authored
Guard log subscribers with initialized check (#2765)
1 parent 997ef4e commit a1680da

File tree

5 files changed

+19
-0
lines changed

5 files changed

+19
-0
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44

55
- Add support for ActiveRecord binds in the log events ([#2761](https://github.com/getsentry/sentry-ruby/pull/2761))
66

7+
### Bug Fixes
8+
9+
- Guard log subscribers with initialized check ([#2765](https://github.com/getsentry/sentry-ruby/pull/2765))
10+
711
## 6.0.0
812

913
### Breaking Changes

sentry-rails/lib/sentry/rails/log_subscribers/action_controller_subscriber.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ class ActionControllerSubscriber < Sentry::Rails::LogSubscriber
2727
#
2828
# @param event [ActiveSupport::Notifications::Event] The controller action event
2929
def process_action(event)
30+
return unless Sentry.initialized?
31+
3032
payload = event.payload
3133

3234
controller = payload[:controller]

sentry-rails/lib/sentry/rails/log_subscribers/action_mailer_subscriber.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ class ActionMailerSubscriber < Sentry::Rails::LogSubscriber
2626
#
2727
# @param event [ActiveSupport::Notifications::Event] The email delivery event
2828
def deliver(event)
29+
return unless Sentry.initialized?
30+
2931
payload = event.payload
3032

3133
mailer = payload[:mailer]
@@ -57,6 +59,8 @@ def deliver(event)
5759
#
5860
# @param event [ActiveSupport::Notifications::Event] The email processing event
5961
def process(event)
62+
return unless Sentry.initialized?
63+
6064
payload = event.payload
6165

6266
mailer = payload[:mailer]

sentry-rails/lib/sentry/rails/log_subscribers/active_job_subscriber.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ class ActiveJobSubscriber < Sentry::Rails::LogSubscriber
2626
#
2727
# @param event [ActiveSupport::Notifications::Event] The job performance event
2828
def perform(event)
29+
return unless Sentry.initialized?
30+
2931
job = event.payload[:job]
3032
duration = duration_ms(event)
3133

@@ -63,6 +65,8 @@ def perform(event)
6365
#
6466
# @param event [ActiveSupport::Notifications::Event] The job enqueue event
6567
def enqueue(event)
68+
return unless Sentry.initialized?
69+
6670
job = event.payload[:job]
6771

6872
attributes = {
@@ -89,6 +93,8 @@ def enqueue(event)
8993
end
9094

9195
def retry_stopped(event)
96+
return unless Sentry.initialized?
97+
9298
job = event.payload[:job]
9399
error = event.payload[:error]
94100

@@ -111,6 +117,8 @@ def retry_stopped(event)
111117
end
112118

113119
def discard(event)
120+
return unless Sentry.initialized?
121+
114122
job = event.payload[:job]
115123
error = event.payload[:error]
116124

sentry-rails/lib/sentry/rails/log_subscribers/active_record_subscriber.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class ActiveRecordSubscriber < Sentry::Rails::LogSubscriber
2929
#
3030
# @param event [ActiveSupport::Notifications::Event] The SQL event
3131
def sql(event)
32+
return unless Sentry.initialized?
3233
return if EXCLUDED_NAMES.include?(event.payload[:name])
3334

3435
sql = event.payload[:sql]

0 commit comments

Comments
 (0)