diff options
author | Sean McGivern <sean@gitlab.com> | 2018-06-15 15:29:55 +0300 |
---|---|---|
committer | Sean McGivern <sean@gitlab.com> | 2018-06-15 15:29:55 +0300 |
commit | d304f883520277334339bf2be1dd20c53a51dc16 (patch) | |
tree | cd5831a1f7bc6c73da8d29940aa745207f98c466 /lib/gitlab | |
parent | 8db7e253b2b3a5145696f92001abbd6481dce3b9 (diff) |
Expose a clean_backtrace method from Gitlab::Profiler
This method makes it easier for other parts of the app to get clean backtraces,
as well as console users.
Diffstat (limited to 'lib/gitlab')
-rw-r--r-- | lib/gitlab/profiler.rb | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/lib/gitlab/profiler.rb b/lib/gitlab/profiler.rb index 18540e64d4c..ecff6ab5d5e 100644 --- a/lib/gitlab/profiler.rb +++ b/lib/gitlab/profiler.rb @@ -11,6 +11,7 @@ module Gitlab lib/gitlab/etag_caching/ lib/gitlab/metrics/ lib/gitlab/middleware/ + ee/lib/gitlab/middleware/ lib/gitlab/performance_bar/ lib/gitlab/request_profiler/ lib/gitlab/profiler.rb @@ -98,11 +99,7 @@ module Gitlab super - backtrace = Rails.backtrace_cleaner.clean(caller) - - backtrace.each do |caller_line| - next if caller_line.match(Regexp.union(IGNORE_BACKTRACES)) - + Gitlab::Profiler.clean_backtrace(caller).each do |caller_line| stripped_caller_line = caller_line.sub("#{Rails.root}/", '') super(" ↳ #{stripped_caller_line}") @@ -112,6 +109,12 @@ module Gitlab end end + def self.clean_backtrace(backtrace) + Array(Rails.backtrace_cleaner.clean(backtrace)).reject do |line| + line.match(Regexp.union(IGNORE_BACKTRACES)) + end + end + def self.with_custom_logger(logger) original_colorize_logging = ActiveSupport::LogSubscriber.colorize_logging original_activerecord_logger = ActiveRecord::Base.logger |