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
14 changes: 14 additions & 0 deletions docs/reference/getting-started-rails.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,17 @@

This automatically sets up error logging and performance tracking but of course there are knobs to turn if you’d like to. See [*Configuration*](/reference/configuration.md).

To load the gem without starting the agent in a particular Rails environment,
set [`enabled`](/reference/configuration.md#config-enabled) to `false`.
Comment thread
smith marked this conversation as resolved.
For example, to start the agent only in production, use ERB in
`config/elastic_apm.yml`:

```yaml
enabled: <%= Rails.env.production? %>
server_url: http://localhost:8200
secret_token: ''
```

You can also set `ELASTIC_APM_ENABLED=false` in an environment where the agent
should not start. The `ElasticAPM` API remains available when the agent is
disabled, but calls that collect data return `nil`.

Check notice on line 47 in docs/reference/getting-started-rails.md

View workflow job for this annotation

GitHub Actions / build / vale

Elastic.WordChoice: Consider using 'deactivated, deselected, hidden, turned off, unavailable' instead of 'disabled', unless the term is in the UI.
16 changes: 16 additions & 0 deletions spec/elastic_apm/rails_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,22 @@
ElasticAPM.stop
end
end

it "doesn't start the agent when disabled by config" do
ElasticAPM::Rails.start(enabled: false)

expect(ElasticAPM.agent).to be nil
expect(ElasticAPM).to_not be_running
end

it "doesn't start the agent when disabled by the environment" do
with_env('ELASTIC_APM_ENABLED' => 'false') do
ElasticAPM::Rails.start({})

expect(ElasticAPM.agent).to be nil
expect(ElasticAPM).to_not be_running
end
end
end

describe 'Rails console' do
Expand Down
Loading