diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-01-06 12:10:31 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-01-06 12:10:31 +0300 |
commit | b3c8b65ec2ab3af29d4d14eac27837e0c4793939 (patch) | |
tree | 8428c98fbb03f62a848ceeef79651172b04a7de4 /lib/gitlab/error_tracking.rb | |
parent | 92bd840b61c7963eb54e0c8de12618b8fe22b715 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/gitlab/error_tracking.rb')
-rw-r--r-- | lib/gitlab/error_tracking.rb | 43 |
1 files changed, 17 insertions, 26 deletions
diff --git a/lib/gitlab/error_tracking.rb b/lib/gitlab/error_tracking.rb index a5ace2be773..e6877d73cf8 100644 --- a/lib/gitlab/error_tracking.rb +++ b/lib/gitlab/error_tracking.rb @@ -111,8 +111,8 @@ module Gitlab private def before_send(event, hint) - event = add_context_from_exception_type(event, hint) - event = custom_fingerprinting(event, hint) + inject_context_for_exception(event, hint[:exception]) + custom_fingerprinting(event, hint[:exception]) event end @@ -123,7 +123,6 @@ module Gitlab end extra = sanitize_request_parameters(extra) - inject_sql_query_into_extra(exception, extra) if sentry && Raven.configuration.server Raven.capture_exception(exception, tags: default_tags, extra: extra) @@ -150,12 +149,6 @@ module Gitlab filter.filter(parameters) end - def inject_sql_query_into_extra(exception, extra) - return unless exception.is_a?(ActiveRecord::StatementInvalid) - - extra[:sql] = PgQuery.normalize(exception.sql.to_s) - end - def sentry_dsn return unless Rails.env.production? || Rails.env.development? return unless Gitlab.config.sentry.enabled @@ -183,9 +176,17 @@ module Gitlab {} end - # Debugging for https://gitlab.com/gitlab-org/gitlab-foss/issues/57727 - def add_context_from_exception_type(event, hint) - if ActiveModel::MissingAttributeError === hint[:exception] + # Group common, mostly non-actionable exceptions by type and message, + # rather than cause + def custom_fingerprinting(event, ex) + return event unless CUSTOM_FINGERPRINTING.include?(ex.class.name) + + event.fingerprint = [ex.class.name, ex.message] + end + + def inject_context_for_exception(event, ex) + case ex + when ActiveModel::MissingAttributeError # Debugging for https://gitlab.com/gitlab-org/gitlab/-/issues/26751 columns_hash = ActiveRecord::Base .connection .schema_cache @@ -193,21 +194,11 @@ module Gitlab .transform_values { |v| v.map(&:first) } event.extra.merge!(columns_hash) + when ActiveRecord::StatementInvalid + event.extra[:sql] = PgQuery.normalize(ex.sql.to_s) + else + inject_context_for_exception(event, ex.cause) if ex.cause.present? end - - event - end - - # Group common, mostly non-actionable exceptions by type and message, - # rather than cause - def custom_fingerprinting(event, hint) - ex = hint[:exception] - - return event unless CUSTOM_FINGERPRINTING.include?(ex.class.name) - - event.fingerprint = [ex.class.name, ex.message] - - event end end end |