Skip to content

Commit

Permalink
Ensure that the running agent's config is used when restarted (#763)
Browse files Browse the repository at this point in the history
* Ensure that the running agent's config is used when restarted

* Add changelog entry
  • Loading branch information
estolfo committed Apr 14, 2020
1 parent 607d985 commit b819708
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ endif::[]
- Ensure that the log level is updated for the config's logger when value is changed {pull}755[#755]
- Set config `false` values to `false`, not `nil` {pull}761[#761]
- Ensure that the previously running agent's config is used in `ElasticAPM.restart` {pull}763[#763]
[float]
===== Added
Expand Down
2 changes: 1 addition & 1 deletion lib/elastic_apm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def stop
# one, if it is provided.
# Starts the agent if it is not running.
# Stops and starts the agent if it is running.
def restart(config = {})
def restart(config = nil)
config ||= agent&.config
stop if running?
start(config)
Expand Down
9 changes: 9 additions & 0 deletions spec/elastic_apm_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,21 @@
end
end
context 'when a new config is passed' do
before { ElasticAPM.start }
it 'restarts the agent with the new config' do
ElasticAPM.restart(api_buffer_size: 10)
expect(ElasticAPM::Agent).to be_running
expect(ElasticAPM.agent.config.api_buffer_size).to be(10)
end
end
context 'when no new config is passed' do
before { ElasticAPM.start(api_buffer_size: 10) }
it 'restarts the agent with the same config' do
ElasticAPM.restart
expect(ElasticAPM::Agent).to be_running
expect(ElasticAPM.agent.config.api_buffer_size).to be(10)
end
end
end

context 'when running', :mock_intake do
Expand Down

0 comments on commit b819708

Please sign in to comment.