Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- Add `before_send_check_in` for applying to `CheckInEvent` ([#2703](https://github.com/getsentry/sentry-ruby/pull/2703))
- Returning a hash from `before_send` and `before_send_transaction` is no longer supported and will drop the event.
- Remove stacktrace trimming ([#2714](https://github.com/getsentry/sentry-ruby/pull/2714))
- `config.enabled_environments` now defaults to `nil` instead of `[]` for sending to all environments ([#2716](https://github.com/getsentry/sentry-ruby/pull/2716))

### Internal

Expand Down
6 changes: 3 additions & 3 deletions sentry-ruby/lib/sentry/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ class Configuration
attr_reader :dsn

# Whitelist of enabled_environments that will send notifications to Sentry. Array of Strings.
# @return [Array<String>]
# @return [Array<String>, nil]
attr_accessor :enabled_environments

# Logger 'progname's to exclude from breadcrumbs
Expand Down Expand Up @@ -459,7 +459,7 @@ def initialize
self.context_lines = 3
self.include_local_variables = false
self.environment = environment_from_env
self.enabled_environments = []
self.enabled_environments = nil
self.exclude_loggers = []
self.excluded_exceptions = IGNORE_DEFAULT + PUMA_IGNORE_DEFAULT
self.inspect_exception_causes_for_exclusion = true
Expand Down Expand Up @@ -647,7 +647,7 @@ def exception_class_allowed?(exc)
end

def enabled_in_current_env?
enabled_environments.empty? || enabled_environments.include?(environment)
enabled_environments.nil? || enabled_environments.include?(environment)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just a remark for now but eventually it would be good to have a more explicit interface for checking if a setting is disabled, something like config.enabled?(:enabled_environments) or something like this, because nil checks are bug prone.

end

def valid_sample_rate?(sample_rate)
Expand Down
1 change: 1 addition & 0 deletions sentry-ruby/lib/sentry/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def setup_sentry_test(&block)
# set transport to DummyTransport, so we can easily intercept the captured events
dummy_config.transport.transport_class = Sentry::DummyTransport
# make sure SDK allows sending under the current environment
dummy_config.enabled_environments ||= []
dummy_config.enabled_environments += [dummy_config.environment] unless dummy_config.enabled_environments.include?(dummy_config.environment)
# disble async event sending
dummy_config.background_worker_threads = 0
Expand Down
3 changes: 1 addition & 2 deletions sentry-ruby/spec/sentry/configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -409,9 +409,8 @@

it 'should send events if test is whitelisted' do
subject.enabled_environments = %w[test]
subject.sending_allowed?
puts subject.errors
expect(subject.sending_allowed?).to eq(true)
expect(subject.errors).to be_empty
end

it 'should not send events if test is not whitelisted' do
Expand Down
Loading