From 7a609858f063c1089f3a6ec05f9f87a01efa909a Mon Sep 17 00:00:00 2001 From: Jeroen Nijhof Date: Wed, 20 Jan 2016 09:48:38 +0100 Subject: [PATCH] Use sentry in env production only --- Gemfile | 6 +++--- .../application_settings/_form.html.haml | 4 +++- config/initializers/sentry.rb | 20 ++++++++++--------- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/Gemfile b/Gemfile index e8fa75e0974..1a91e9cc3e8 100644 --- a/Gemfile +++ b/Gemfile @@ -293,6 +293,9 @@ end group :production do gem "gitlab_meta", '7.0' + + # Sentry integration + gem 'sentry-raven' end gem "newrelic_rpm", '~> 3.9.4.245' @@ -314,6 +317,3 @@ gem 'oauth2', '~> 1.0.0' # Soft deletion gem "paranoia", "~> 2.0" - -# Sentry integration -gem 'sentry-raven' diff --git a/app/views/admin/application_settings/_form.html.haml b/app/views/admin/application_settings/_form.html.haml index 35af5cf620a..f5a87933fde 100644 --- a/app/views/admin/application_settings/_form.html.haml +++ b/app/views/admin/application_settings/_form.html.haml @@ -242,7 +242,9 @@ = f.label :sentry_enabled do = f.check_box :sentry_enabled Enable Sentry - %span.help-block#sentry_help_block Sentry is an error reporting and logging tool + .help-block + Sentry is an error reporting and logging tool which is currently not shipped with GitLab, get it here: + %a{ href: 'https://getsentry.com', target: 'blank' } https://getsentry.com .form-group = f.label :sentry_dsn, 'Sentry DSN', class: 'control-label col-sm-2' diff --git a/config/initializers/sentry.rb b/config/initializers/sentry.rb index 3ef46291981..d0630b9fa07 100644 --- a/config/initializers/sentry.rb +++ b/config/initializers/sentry.rb @@ -3,15 +3,17 @@ require 'gitlab/current_settings' include Gitlab::CurrentSettings -# allow it to fail: it may do so when create_from_defaults is executed before migrations are actually done -begin - sentry_enabled = current_application_settings.sentry_enabled -rescue - sentry_enabled = false -end +if Rails.env.production? + # allow it to fail: it may do so when create_from_defaults is executed before migrations are actually done + begin + sentry_enabled = current_application_settings.sentry_enabled + rescue + sentry_enabled = false + end -if sentry_enabled - Raven.configure do |config| - config.dsn = current_application_settings.sentry_dsn + if sentry_enabled + Raven.configure do |config| + config.dsn = current_application_settings.sentry_dsn + end end end