diff options
Diffstat (limited to 'lib/gitlab/sentry.rb')
-rw-r--r-- | lib/gitlab/sentry.rb | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/gitlab/sentry.rb b/lib/gitlab/sentry.rb index 4a22fc80f75..6381e94c1d2 100644 --- a/lib/gitlab/sentry.rb +++ b/lib/gitlab/sentry.rb @@ -18,6 +18,25 @@ module Gitlab end end + # This can be used for investigating exceptions that can be recovered from in + # code. The exception will still be raised in development and test + # environments. + # + # That way we can track down these exceptions with as much information as we + # need to resolve them. + # + # Provide an issue URL for follow up. + def self.track_exception(exception, issue_url: nil, extra: {}) + if enabled? + extra[:issue_url] = issue_url if issue_url + context # Make sure we've set everything we know in the context + + Raven.capture_exception(exception, extra: extra) + end + + raise exception if should_raise? + end + def self.program_context if Sidekiq.server? 'sidekiq' @@ -25,5 +44,9 @@ module Gitlab 'rails' end end + + def self.should_raise? + Rails.env.development? || Rails.env.test? + end end end |