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.
This commit is contained in:
Sean McGivern 2019-05-03 12:31:01 +01:00
parent 9f8123d935
commit 179676aecb

View file

@ -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