-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add `config/appsignal.rb` config file support. This is a replacement for the `config/appsignal.yml` config file. Load the `config/appsignal.rb` file automatically on `Appsignal.start`. For most apps, like Rails apps, this will work the same way as `config/appsignal.yml` does now. If `Appsignal.configure` is called manually in the app, like a Rails initializer, the `config/appsignal.rb` file is not loaded. Instead, we recommend moving the `Appsignal.configure` call to the `config/appsignal.rb` file. ## New behavior With this change the config is loaded as described in these scenarios: - Scenario 1: - `Appsignal.start` is called. - No config is loaded yet. - The `config/appsignal.rb` file is present. - The `config/appsignal.rb` is required and configures the gem. - Scenario 2: - `Appsignal.start` is called. - No config is loaded yet. - The `config/appsignal.rb` file is present. - The `config/appsignal.yml` file is present. - The `config/appsignal.rb` is required and configures the gem using the `Appsignal.configure` helper. - The `config/appsignal.yml` is not loaded. - Scenario 3: - `Appsignal.configure` is called. - The `config/appsignal.rb` file is present. - The `config/appsignal.rb` file is not loaded. - `Appsignal.start` is called. - Scenario 4: - `Appsignal.configure` is called. - The `config/appsignal.yml` file is present. - The `config/appsignal.yml` file is loaded. - `Appsignal.start` is called. This is more complex that I would have liked. In hindsight I shouldn't have made `Appsignal.configure` load the `config/appsignal.yml` file. That would have made it a bit more predictable. But I don't want `Appsignal.configure` in the `config/appsignal.rb` file to also load the `config/appsignal.yml` file, because then it just gets more confusing. In the next major version I want to remove `config/appsignal.yml` support, so this is the first step. ## App/root path I remember some of our users configured the Config class's `root_path` to specify where to load the config file from. If an app configures itself via a `config/appsignal.rb`, this makes it impossible to customize the root path. For that purpose I've added the `APPSIGNAL_APP_PATH` environment variable to customize the config path. Which I've also used to make it easier to test the different scenarios. --- Part of #1324
- Loading branch information
Showing
6 changed files
with
371 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--- | ||
bump: minor | ||
type: add | ||
--- | ||
|
||
Add `config/appsignal.rb` config file support. When a `config/appsignal.rb` file is present in the app, the Ruby gem will automatically load it when `Appsignal.start` is called. | ||
|
||
The `config/appsignal.rb` config file is a replacement for the `config/appsignal.yml` config file. When both files are present, only the `config/appsignal.rb` config file is loaded. | ||
|
||
Example `config/appsignal.rb` config file: | ||
|
||
```ruby | ||
# config/appsignal.rb | ||
Appsignal.configure do |config| | ||
config.name = "My app name" | ||
end | ||
``` | ||
|
||
It is not possible to configure multiple environments in the `config/appsignal.rb` config file as it was possible in the YAML version. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.