Skip to content

Commit ac534f3

Browse files
chore(ruby): Remove unused Configuration error tracking (#3164)
* chore(ruby): Remove unused Configuration#error_messages Its last caller was removed in #1601 when the transport stopped checking sending_allowed?. The method is @api private and nothing in the monorepo calls it. * chore(ruby): Remove unused Configuration#errors tracking With error_messages gone, nothing reads @errors outside of specs. Drop the private errors reader and the helpers that only existed to populate it, which also stops sending_to_dsn_allowed? from mutating state on every call. Co-Authored-By: Neel Shah <6536764+sl0thentr0py@users.noreply.github.com> --------- Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> Co-authored-by: Neel Shah <6536764+sl0thentr0py@users.noreply.github.com>
1 parent b0671d3 commit ac534f3

2 files changed

Lines changed: 2 additions & 29 deletions

File tree

‎sentry-ruby/lib/sentry/configuration.rb‎

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ def include_local_variables=(value)
421421

422422
# these are not config options
423423
# @!visibility private
424-
attr_reader :errors, :gem_specs
424+
attr_reader :gem_specs
425425

426426
# These exceptions could enter Puma's `lowlevel_error_handler` callback and the SDK's Puma integration
427427
# But they are mostly considered as noise and should be ignored by default
@@ -764,9 +764,7 @@ def sending_allowed?
764764
end
765765

766766
def sending_to_dsn_allowed?
767-
@errors = []
768-
769-
valid? && capture_in_environment?
767+
!!@dsn&.valid? && enabled_in_current_env?
770768
end
771769

772770
def sample_allowed?
@@ -856,12 +854,6 @@ def detect_release
856854
log_error("Error detecting release", e, debug: debug)
857855
end
858856

859-
# @api private
860-
def error_messages
861-
@errors = [@errors[0]] + @errors[1..-1].map(&:downcase) # fix case of all but first
862-
@errors.join(", ")
863-
end
864-
865857
# @api private
866858
def run_after_close_callbacks
867859
run_callbacks(:after, :closed)
@@ -908,22 +900,6 @@ def safe_const_get(x)
908900
nil
909901
end
910902

911-
def capture_in_environment?
912-
return true if enabled_in_current_env?
913-
914-
@errors << "Not configured to send/capture in environment '#{environment}'"
915-
false
916-
end
917-
918-
def valid?
919-
if @dsn&.valid?
920-
true
921-
else
922-
@errors << "DSN not set or not valid"
923-
false
924-
end
925-
end
926-
927903
def environment_from_env
928904
ENV["SENTRY_CURRENT_ENV"] || ENV["SENTRY_ENVIRONMENT"] || ENV["RAILS_ENV"] || ENV["RACK_ENV"] || "development"
929905
end

‎sentry-ruby/spec/sentry/configuration_spec.rb‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -476,13 +476,11 @@
476476
it 'should send events if test is whitelisted' do
477477
subject.enabled_environments = %w[test]
478478
expect(subject.sending_allowed?).to eq(true)
479-
expect(subject.errors).to be_empty
480479
end
481480

482481
it 'should not send events if test is not whitelisted' do
483482
subject.enabled_environments = %w[not_test]
484483
expect(subject.sending_allowed?).to eq(false)
485-
expect(subject.errors).to eq(["Not configured to send/capture in environment 'test'"])
486484
end
487485
end
488486

@@ -551,7 +549,6 @@
551549

552550
it 'captured_allowed returns false' do
553551
expect(subject.sending_allowed?).to eq(false)
554-
expect(subject.errors).to eq(["DSN not set or not valid"])
555552
end
556553
end
557554

0 commit comments

Comments
 (0)