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

Config as production but sent sentry as staging env? #929

Closed
gamesover opened this issue Oct 15, 2019 · 3 comments
Closed

Config as production but sent sentry as staging env? #929

gamesover opened this issue Oct 15, 2019 · 3 comments

Comments

@gamesover
Copy link

gamesover commented Oct 15, 2019

Hi, my current rails project hosted in heroku is staging. However, according to heroku's recommandation, there is no seperate staging env config in my project. So all info are the same as production. As a result, when exception throw out, I still hope they sent to sentry as staging errors, not production errors.

How to do that?

@st0012 st0012 added this to Low priority in 3.x Aug 6, 2020
@st0012
Copy link
Collaborator

st0012 commented Feb 18, 2021

@gamesover sorry for the delayed response. is it still troubling you?

@pil0u
Copy link

pil0u commented Apr 3, 2021

For @gamesover (1.5 years later ⌛) and others who might encounter this problem, here is my workaround.

  1. I set a new environment variable HEROKU_PIPELINE_STEP in Heroku's configuration, which value can be review (for my Review Apps), staging or production
  2. I use the following configuration in Rails, in my config/initializers/sentry.rb file:
config.environment = ENV["HEROKU_PIPELINE_STEP"] || ENV["RAILS_ENV"]

That way, you can separate these environments in your Sentry monitoring, thus having staging errors in the correct staging environment.

If you don't set the HEROKU_PIPELINE_STEP variable, it just fall backs to the default behaviour: getting the RAILS_ENV (which can be indeed impractical if you follow Heroku's guidelines to use RAILS_ENV=production for all your apps).

Note that as @jonekdahl mentioned in #885, you (still) cannot run the heroku labs:enable runtime-dyno-metadata -a <app_name> command in Review Apps, so you will be stuck with Sentry's warning in Review Apps.

@st0012
Copy link
Collaborator

st0012 commented Jun 11, 2021

@pil0u thanks for the great suggestion 👍
@gamesover I think @pil0u's comment is the best solution here and I recommend you to give it a try 🙂
I'm going to close this now.

@st0012 st0012 closed this as completed Jun 11, 2021
3.x automation moved this from Medium priority to Closed Jun 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
3.x
  
Closed
Development

No branches or pull requests

3 participants