summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean McGivern <sean@gitlab.com>2019-05-03 12:31:01 +0100
committerSean McGivern <sean@gitlab.com>2019-05-03 12:32:48 +0100
commit179676aecb73244b352da9e85a981bc0df66ab4b (patch)
treec01d9ddbc480625f5f0da59115c499bfda74bedf
parent9f8123d935679582ac4f1487e1dcb559863372cb (diff)
downloadgitlab-ce-179676aecb73244b352da9e85a981bc0df66ab4b.tar.gz
Include all queries in the performance bar summary
Rails 5.1's `exec_no_cache` doesn't call `async_exec` any more, but `exec_params`: https://github.com/rails/rails/pull/33188 This means that the DB summary in the performance bar was wrong. The individual query details were still correct (we subscribe to ActiveRecord events for those). We can remove this once the upstream PR to peek-pg is in a release and we update to use that release.
-rw-r--r--config/initializers/peek.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/config/initializers/peek.rb b/config/initializers/peek.rb
index eeb45fae753..cb108416b10 100644
--- a/config/initializers/peek.rb
+++ b/config/initializers/peek.rb
@@ -10,6 +10,18 @@ elsif Gitlab::Database.postgresql?
require 'peek-pg'
PEEK_DB_CLIENT = ::PG::Connection
PEEK_DB_VIEW = Peek::Views::PG
+
+ # Remove once we have https://github.com/peek/peek-pg/pull/10
+ module ::Peek::PGInstrumented
+ def exec_params(*args)
+ start = Time.now
+ super(*args)
+ ensure
+ duration = (Time.now - start)
+ PEEK_DB_CLIENT.query_time.update { |value| value + duration }
+ PEEK_DB_CLIENT.query_count.update { |value| value + 1 }
+ end
+ end
else
raise "Unsupported database adapter for peek!"
end