Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean McGivern <sean@gitlab.com>2019-07-26 16:03:00 +0300
committerSean McGivern <sean@gitlab.com>2019-07-26 16:37:26 +0300
commitad1c71663f7780838c7c90979419f3e3cf5ec580 (patch)
tree59443b9ea0f860511610acf181e1eadbc8c88d34 /lib/peek/views/active_record.rb
parent55f99e930e1c147ec191a234ff4881ea7e70ea61 (diff)
Replace peek-pg with our own implementation
This uses an ActiveRecord subscriber to get queries and calculate the total query time from that. This means that the total will always be consistent with the queries in the table. It does however mean that we could potentially miss some queries that don't go through ActiveRecord. Making this change also allows us to unify the response JSON a little bit, making the frontend slightly simpler as a result.
Diffstat (limited to 'lib/peek/views/active_record.rb')
-rw-r--r--lib/peek/views/active_record.rb25
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/peek/views/active_record.rb b/lib/peek/views/active_record.rb
new file mode 100644
index 00000000000..2d78818630d
--- /dev/null
+++ b/lib/peek/views/active_record.rb
@@ -0,0 +1,25 @@
+# frozen_string_literal: true
+
+module Peek
+ module Views
+ class ActiveRecord < DetailedView
+ private
+
+ def setup_subscribers
+ super
+
+ subscribe('sql.active_record') do |_, start, finish, _, data|
+ if Gitlab::SafeRequestStore.store[:peek_enabled]
+ unless data[:cached]
+ detail_store << {
+ duration: finish - start,
+ sql: data[:sql].strip,
+ backtrace: Gitlab::Profiler.clean_backtrace(caller)
+ }
+ end
+ end
+ end
+ end
+ end
+ end
+end