Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid invoking ActiveSupport::BroadcastLogger if not defined #2169

Merged
merged 3 commits into from
Nov 21, 2023

Conversation

PetrHeinz
Copy link
Contributor

@PetrHeinz PetrHeinz commented Nov 13, 2023

Description

When ::ActiveSupport::BroadcastLogger is not defined (Rails < 7.1) and ::Rails.logger instance has broadcasts method defined, initialization of Sentry-ruby fails on NameError: uninitialized constant ActiveSupport::BroadcastLogger (NameError).

I suggest changing the check to ::Rails.logger being an instance of ::ActiveSupport::BroadcastLogger (with a defined? check).

Copy link

codecov bot commented Nov 21, 2023

Codecov Report

Merging #2169 (6f46a71) into master (e082644) will increase coverage by 0.09%.
Report is 2 commits behind head on master.
The diff coverage is 100.00%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2169      +/-   ##
==========================================
+ Coverage   97.30%   97.40%   +0.09%     
==========================================
  Files          97       98       +1     
  Lines        3638     3655      +17     
==========================================
+ Hits         3540     3560      +20     
+ Misses         98       95       -3     
Components Coverage Δ
sentry-ruby 98.02% <ø> (+<0.01%) ⬆️
sentry-rails 94.98% <100.00%> (ø)
sentry-sidekiq 95.54% <ø> (+1.83%) ⬆️
sentry-resque 93.65% <ø> (+1.58%) ⬆️
sentry-delayed_job 94.36% <ø> (ø)
sentry-opentelemetry 100.00% <ø> (ø)
Files Coverage Δ
sentry-rails/lib/sentry/rails/configuration.rb 97.14% <100.00%> (ø)

... and 4 files with indirect coverage changes

@st0012 st0012 changed the title Avoid instantiating BroadcastLogger if not defined Avoid invoking ActiveSupport::BroadcastLogger if not defined Nov 21, 2023
Copy link
Collaborator

@st0012 st0012 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't aware the other loggers could also have braodcasts method too. Thanks for the fix 👍

CHANGELOG.md Outdated Show resolved Hide resolved
@st0012 st0012 added the bug fix label Nov 21, 2023
@st0012 st0012 merged commit 4edfdf1 into getsentry:master Nov 21, 2023
97 checks passed
@PetrHeinz PetrHeinz deleted the patch-1 branch November 24, 2023 10:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants