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

Add Config active_if_environment helper #1323

Merged
merged 2 commits into from
Nov 4, 2024
Merged

Conversation

tombruijn
Copy link
Member

Help people configure AppSignal using the Appsignal.configure helper more easily by adding the activate_if_environment helper within that DSL context.

This helper will automate setting active to true if the loaded environment matches one of the values given.

This way people don't have build their own conditionals to set active true for certain environments.

Help people configure AppSignal using the `Appsignal.configure` helper
more easily by adding the `activate_if_environment` helper within that
DSL context.

This helper will automate setting `active` to `true` if the loaded
environment matches one of the values given.

This way people don't have build their own conditionals to set active
true for certain environments.
Copy link
Contributor

@unflxw unflxw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not opposed to this change, but I'm not sure I understand the use case. I may be missing something. Is it only a convenience wrapper for config.active = ["production", "staging"].include?(config.environment), or is there more to it?

.changesets/add-activate_if_environment-helper.md Outdated Show resolved Hide resolved
@backlog-helper
Copy link

backlog-helper bot commented Nov 4, 2024


This is a message from the daily scheduled checks.

New issue guide | Backlog management | Rules | Feedback

@tombruijn
Copy link
Member Author

Is it only a convenience wrapper for config.active = ["production", "staging"].include?(config.environment), or is there more to it?

Yes. It's to promote this pattern of setting the active option using the AppSignal env, rather than use Rails.env which may not be in sync with the AppSignal env, which leads to unexpected outcomes.

For example: this scenario where the rails env is production in staging and AppSignal shouldn't be active in staging.

ENV["RAILS_ENV"] = "production"
ENV["APPSIGNAL_APP_ENV"] = "staging"

# config/initializers/appsignal.rb
Appsignal.configure do |config|
  config.env # => "staging"
  config.active = Rails.env.production?
end

@tombruijn tombruijn merged commit ff31be8 into main Nov 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants