summaryrefslogtreecommitdiff
path: root/lib/peek
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-04-20 23:50:22 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-04-20 23:50:22 +0000
commit9dc93a4519d9d5d7be48ff274127136236a3adb3 (patch)
tree70467ae3692a0e35e5ea56bcb803eb512a10bedb /lib/peek
parent4b0f34b6d759d6299322b3a54453e930c6121ff0 (diff)
downloadgitlab-ce-9dc93a4519d9d5d7be48ff274127136236a3adb3.tar.gz
Add latest changes from gitlab-org/gitlab@13-11-stable-eev13.11.0-rc43
Diffstat (limited to 'lib/peek')
-rw-r--r--lib/peek/views/active_record.rb30
1 files changed, 21 insertions, 9 deletions
diff --git a/lib/peek/views/active_record.rb b/lib/peek/views/active_record.rb
index 523e673e9e1..4040bed50a9 100644
--- a/lib/peek/views/active_record.rb
+++ b/lib/peek/views/active_record.rb
@@ -17,22 +17,32 @@ module Peek
}
}.freeze
- def results
- super.merge(calls: detailed_calls)
- end
-
def self.thresholds
@thresholds ||= THRESHOLDS.fetch(Rails.env.to_sym, DEFAULT_THRESHOLDS)
end
+ def results
+ super.merge(summary: summary)
+ end
+
private
- def detailed_calls
- "#{calls} (#{cached_calls} cached)"
+ def summary
+ detail_store.each_with_object({}) do |item, count|
+ count_summary(item, count)
+ end
end
- def cached_calls
- detail_store.count { |item| item[:cached] == 'cached' }
+ def count_summary(item, count)
+ if item[:cached].present?
+ count[item[:cached]] ||= 0
+ count[item[:cached]] += 1
+ end
+
+ if item[:transaction].present?
+ count[item[:transaction]] ||= 0
+ count[item[:transaction]] += 1
+ end
end
def setup_subscribers
@@ -45,10 +55,12 @@ module Peek
def generate_detail(start, finish, data)
{
+ start: start,
duration: finish - start,
sql: data[:sql].strip,
backtrace: Gitlab::BacktraceCleaner.clean_backtrace(caller),
- cached: data[:cached] ? 'cached' : ''
+ cached: data[:cached] ? 'Cached' : '',
+ transaction: data[:connection].transaction_open? ? 'In a transaction' : ''
}
end
end