diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-10-21 07:08:36 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-10-21 07:08:36 +0000 |
commit | 48aff82709769b098321c738f3444b9bdaa694c6 (patch) | |
tree | e00c7c43e2d9b603a5a6af576b1685e400410dee /lib/peek | |
parent | 879f5329ee916a948223f8f43d77fba4da6cd028 (diff) | |
download | gitlab-ce-48aff82709769b098321c738f3444b9bdaa694c6.tar.gz |
Add latest changes from gitlab-org/gitlab@13-5-stable-eev13.5.0-rc42
Diffstat (limited to 'lib/peek')
-rw-r--r-- | lib/peek/views/active_record.rb | 25 | ||||
-rw-r--r-- | lib/peek/views/detailed_view.rb | 2 |
2 files changed, 19 insertions, 8 deletions
diff --git a/lib/peek/views/active_record.rb b/lib/peek/views/active_record.rb index ed3470f81f4..77108bb81ca 100644 --- a/lib/peek/views/active_record.rb +++ b/lib/peek/views/active_record.rb @@ -17,24 +17,35 @@ module Peek } }.freeze + def results + super.merge(calls: detailed_calls) + end + def self.thresholds @thresholds ||= THRESHOLDS.fetch(Rails.env.to_sym, DEFAULT_THRESHOLDS) end private + def detailed_calls + "#{calls} (#{cached_calls} cached)" + end + + def cached_calls + detail_store.count { |item| item[:cached] == 'cached' } + end + def setup_subscribers super subscribe('sql.active_record') do |_, start, finish, _, data| if Gitlab::PerformanceBar.enabled_for_request? - unless data[:cached] - detail_store << { - duration: finish - start, - sql: data[:sql].strip, - backtrace: Gitlab::BacktraceCleaner.clean_backtrace(caller) - } - end + detail_store << { + duration: finish - start, + sql: data[:sql].strip, + backtrace: Gitlab::BacktraceCleaner.clean_backtrace(caller), + cached: data[:cached] ? 'cached' : '' + } end end end diff --git a/lib/peek/views/detailed_view.rb b/lib/peek/views/detailed_view.rb index 389f5301079..4cc2e85c7bb 100644 --- a/lib/peek/views/detailed_view.rb +++ b/lib/peek/views/detailed_view.rb @@ -23,7 +23,7 @@ module Peek private def duration - detail_store.map { |entry| entry[:duration] }.sum * 1000 # rubocop:disable CodeReuse/ActiveRecord + detail_store.map { |entry| entry[:duration] }.sum * 1000 end def calls |