-
-
Notifications
You must be signed in to change notification settings - Fork 505
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
Allow current_environment
to be set via an env variable
#736
Allow current_environment
to be set via an env variable
#736
Conversation
This commit allows developers to set a `SENTRY_CURRENT_ENV` variable to configure the `current_environment` setting. It serves as a fix for this scenario: We run our production/staging/integration environments with Rails env "production". To differentiate errors from the environments we set `config.current_environment` with an environment variable (https://github.com/alphagov/content-tagger/blob/bac2e1903aaf6ac12b3a103 490517355673648dd/config/initializers/sentry.rb#L2). However, this doesn't work in all situations. For example, when you run a rake task that doesn't exist, an error will be reported to Sentry. Because the initialiser that sets the `current_environment` hasn't run (yet) Sentry will use the `RAILS_ENV` to determine the current env. This causes all errors to be reported as production instead of production/staging/integration.
Couldn't you also fix this by requiring the initializer at the top of your Rakefile? |
Yep, that would also work in this case. However, we're migrating over 50 applications to Sentry, so for us this would be a not insignificant amount of work. Additionally this option would probably allow us to configure everything via the environment and skip the initialiser entirely, which makes adoption a lot easier for us. |
This sets the current environment for Sentry to the value currently used for errbit, so either integration/staging/production (getsentry/sentry-ruby#736).
This sets the current environment for Sentry to the value currently used for errbit, so either integration/staging/production (getsentry/sentry-ruby#736).
This sets the current environment for Sentry to the value currently used for errbit, so either integration/staging/production (getsentry/sentry-ruby#736).
This sets the current environment for Sentry to the value currently used for errbit, so either integration/staging/production (getsentry/sentry-ruby#736).
This sets the current environment for Sentry to the value currently used for errbit, so either integration/staging/production (getsentry/sentry-ruby#736).
Release commit: getsentry/sentry-ruby@ef623824cb0a8a2f60be5fb7e 12f80454da54fd7 This release includes the PR to set the Sentry environment with `SENTRY_CURRENT_ENV`, which means that Sentry will report the correct env even when the configuration hasn't loaded yet (getsentry/sentry-ruby#736). It simplifies our local config.
Release commit: getsentry/sentry-ruby@ef623824cb0a8a2f60be5fb7e 12f80454da54fd7 This release includes the PR to set the Sentry environment with `SENTRY_CURRENT_ENV`, which means that Sentry will report the correct env even when the configuration hasn't loaded yet (getsentry/sentry-ruby#736). It simplifies our local config.
This commit allows developers to set a
SENTRY_CURRENT_ENV
variable to configure thecurrent_environment
setting.It serves as a fix for this scenario:
We run our production/staging/integration environments with Rails env "production". To differentiate errors from the environments we set
config.current_environment
with an environment variable:https://github.com/alphagov/content-tagger/blob/bac2e1903aaf6ac12b3a103490517355673648dd/config/initializers/sentry.rb#L1-L3
However, this doesn't work in all situations. For example, when you run a rake task that doesn't exist, an error will be reported to Sentry. Because the initialiser that sets the
current_environment
hasn't run (yet) Sentry will use theRAILS_ENV
to determine the current env. This causes all errors to be reported as "production" instead of production/staging/integration.