diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-11-22 06:06:14 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-11-22 06:06:14 +0300 |
commit | f519cec2ad00c08b03614addd39a0d1a81c5d236 (patch) | |
tree | 59293b4a603c2ac8e20ac94f4a35490f28eb54d0 /lib/gitlab/exception_log_formatter.rb | |
parent | 157f9a451a428f66666ba85d8b880df78aff6cc4 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/gitlab/exception_log_formatter.rb')
-rw-r--r-- | lib/gitlab/exception_log_formatter.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/gitlab/exception_log_formatter.rb b/lib/gitlab/exception_log_formatter.rb new file mode 100644 index 00000000000..e0de0219294 --- /dev/null +++ b/lib/gitlab/exception_log_formatter.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +module Gitlab + module ExceptionLogFormatter + def self.format!(exception, payload) + return unless exception + + # Elasticsearch/Fluentd don't handle nested structures well. + # Use periods to flatten the fields. + payload.merge!( + 'exception.class' => exception.class.name, + 'exception.message' => exception.message + ) + + if exception.backtrace + payload['exception.backtrace'] = Gitlab::Profiler.clean_backtrace(exception.backtrace) + end + end + end +end |