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

config: don't poll remote config if the current env is ignored #685

Merged
merged 1 commit into from
Apr 13, 2022
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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ Airbrake Ruby Changelog
* Fixed `Errno::EAGAIN`, which may happen in certain environments when
configuring Airbrake
([#684](https://github.com/airbrake/airbrake-ruby/pull/684))
* The `ignore_environments` option can now control remote configuration. If the
current `environment` matches an environment specified in
`ignore_environments`, then the remote configuration won't be fetched. This is
equivalent to having `remote_config = false`
([#685](https://github.com/airbrake/airbrake-ruby/pull/685))

### [v6.0.2][v6.0.2] (January 10, 2022)

Expand Down
6 changes: 6 additions & 0 deletions lib/airbrake-ruby/config/processor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,14 @@ def process_allowlist(notifier)
def process_remote_configuration
return unless @config.remote_config
return unless @project_id

# Never poll remote configuration in the test environment.
return if @config.environment == 'test'

# If the current environment is ignored, don't try to poll remote
# configuration.
return if @config.ignore_environments.include?(@config.environment)

RemoteSettings.poll(@project_id, @config.remote_config_host) do |data|
@poll_callback.call(data)
end
Expand Down
16 changes: 16 additions & 0 deletions spec/config/processor_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,22 @@
end
end

context "when the config sets :ignore_environments and :environment matches" do
let(:config) do
Airbrake::Config.new(
project_id: 123,
ignore_environments: %w[dev],
environment: 'dev',
)
end

it "doesn't set remote settings" do
described_class.new(config).process_remote_configuration

expect(Airbrake::RemoteSettings).not_to have_received(:poll)
end
end

context "when the config defines a project_id" do
let(:config) do
Airbrake::Config.new(project_id: 123, environment: 'not-test')
Expand Down