Skip to content

Conversation

@eugeneius
Copy link
Contributor

The release can be set manually by the user. The typical way to do that would be to create an initializer:

# config/initializers/raven.rb
Raven.configure do |config|
  config.release = ENV['RELEASE']
end

The hook in the Rails integration that tries to automatically detect a release is run after the app's initializers, which means it clobbers any value that has already been set - even if it can't detect a release, it sets the value back to nil.

If the user has set a release themselves, we shouldn't try to detect it.

@nateberkopec
Copy link
Contributor

Ack, that's definitely not intended.

The problem is with a Cap-deployed app with a .git folder. In that case, when the client is initialized, we set the release to the short Git SHA ("asdaf" or whatever). project_root only gets properly set when Rails is initialized, which happens after the client is initialized, so that's why I was re-running detect_release with a bare =.

This allows users to override the detected release in an initializer.

The before_initialize hook was added in Rails 3.0, which is the oldest
version we support. Both Rails.logger and Rails.root are available when
it runs.
@eugeneius eugeneius force-pushed the fix_release_configuration branch from d7eb229 to 58fc0ee Compare February 4, 2016 00:31
@eugeneius eugeneius changed the title Don't try to detect a release if it's already set Detect release before application initializers run Feb 4, 2016
@eugeneius
Copy link
Contributor Author

Okay, I've taken a different approach here: we now set project_root and try to detect the release before the application initializers are run.

The before_initialize hook was added in Rails 3.0, which is the oldest version we support. Both Rails.logger and Rails.root are available when it runs.

nateberkopec added a commit that referenced this pull request Feb 4, 2016
Detect release before application initializers run
@nateberkopec nateberkopec merged commit 704b3b8 into getsentry:master Feb 4, 2016
@nateberkopec
Copy link
Contributor

Thanks!

rspeicher referenced this pull request in gitlabhq/gitlabhq Feb 24, 2016
Update sentry-raven to 0.15.6

Fixes a few bugs, most notably (for our purposes): https://github.com/getsentry/raven-ruby/pull/450

See merge request !2947
rymai referenced this pull request in gitlabhq/gitlabhq Feb 24, 2016
Update sentry-raven to 0.15.6

Fixes a few bugs, most notably (for our purposes): https://github.com/getsentry/raven-ruby/pull/450

See merge request !2947
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants