Skip to content

Commit

Permalink
Merge pull request #685 from airbrake/679-ignore-environments-remote-…
Browse files Browse the repository at this point in the history
…config

config: don't poll remote config if the current env is ignored
  • Loading branch information
kyrylo authored Apr 13, 2022
2 parents 64c4644 + daa7f3f commit b3fc170
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
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

0 comments on commit b3fc170

Please sign in to comment.