diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-06-20 14:10:13 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-06-20 14:10:13 +0300 |
commit | 0ea3fcec397b69815975647f5e2aa5fe944a8486 (patch) | |
tree | 7979381b89d26011bcf9bdc989a40fcc2f1ed4ff /lib/gitlab/error_tracking.rb | |
parent | 72123183a20411a36d607d70b12d57c484394c8e (diff) |
Add latest changes from gitlab-org/gitlab@15-1-stable-eev15.1.0-rc42
Diffstat (limited to 'lib/gitlab/error_tracking.rb')
-rw-r--r-- | lib/gitlab/error_tracking.rb | 35 |
1 files changed, 16 insertions, 19 deletions
diff --git a/lib/gitlab/error_tracking.rb b/lib/gitlab/error_tracking.rb index f9959d5677b..35c1a1e73cf 100644 --- a/lib/gitlab/error_tracking.rb +++ b/lib/gitlab/error_tracking.rb @@ -67,7 +67,7 @@ module Gitlab # `extra`. Exceptions can use this mechanism to provide structured data # to sentry in addition to their message and back-trace. def track_and_raise_exception(exception, extra = {}) - process_exception(exception, sentry: true, extra: extra) + process_exception(exception, extra: extra) raise exception end @@ -87,7 +87,7 @@ module Gitlab # Provide an issue URL for follow up. # as `issue_url: 'http://gitlab.com/gitlab-org/gitlab/issues/111'` def track_and_raise_for_dev_exception(exception, extra = {}) - process_exception(exception, sentry: true, extra: extra) + process_exception(exception, extra: extra) raise exception if should_raise_for_dev? end @@ -99,7 +99,7 @@ module Gitlab # `extra`. Exceptions can use this mechanism to provide structured data # to sentry in addition to their message and back-trace. def track_exception(exception, extra = {}) - process_exception(exception, sentry: true, extra: extra) + process_exception(exception, extra: extra) end # This should be used when you only want to log the exception, @@ -110,7 +110,7 @@ module Gitlab # `extra`. Exceptions can use this mechanism to provide structured data # to sentry in addition to their message and back-trace. def log_exception(exception, extra = {}) - process_exception(exception, extra: extra) + process_exception(exception, extra: extra, trackers: [Logger]) end private @@ -136,25 +136,22 @@ module Gitlab end end - def process_exception(exception, sentry: false, logging: true, extra:) + def process_exception(exception, extra:, trackers: default_trackers) context_payload = Gitlab::ErrorTracking::ContextPayloadGenerator.generate(exception, extra) - if sentry && Raven.configuration.server - Raven.capture_exception(exception, **context_payload) + trackers.each do |tracker| + tracker.capture_exception(exception, **context_payload) end + end - # There is a possibility that this method is called before Sentry is - # configured. Since Sentry 4.0, some methods of Sentry are forwarded to - # to `nil`, hence we have to check the client as well. - if sentry && ::Sentry.get_current_client && ::Sentry.configuration.dsn - ::Sentry.capture_exception(exception, **context_payload) - end - - if logging - formatter = Gitlab::ErrorTracking::LogFormatter.new - log_hash = formatter.generate_log(exception, context_payload) - - Gitlab::ErrorTracking::Logger.error(log_hash) + def default_trackers + [].tap do |destinations| + destinations << Raven if Raven.configuration.server + # There is a possibility that this method is called before Sentry is + # configured. Since Sentry 4.0, some methods of Sentry are forwarded to + # to `nil`, hence we have to check the client as well. + destinations << ::Sentry if ::Sentry.get_current_client && ::Sentry.configuration.dsn + destinations << Logger end end |