Commit 9c70d98e authored by Sean McGivern's avatar Sean McGivern

Merge branch '34940-peek-performance-bar-doesn-t-count-cached-queries-but-shows-them' into 'master'

Resolve "Peek performance bar doesn't count cached queries, but shows them"

Closes #34940

See merge request !12915
parents 48257533 32eaf46e
# Inspired by https://github.com/peek/peek-pg/blob/master/lib/peek/views/pg.rb # Inspired by https://github.com/peek/peek-pg/blob/master/lib/peek/views/pg.rb
# PEEK_DB_CLIENT is a constant set in config/initializers/peek.rb
module Gitlab module Gitlab
module PerformanceBar module PerformanceBar
module PeekQueryTracker module PeekQueryTracker
...@@ -23,10 +24,16 @@ module Gitlab ...@@ -23,10 +24,16 @@ module Gitlab
subscribe('sql.active_record') do |_, start, finish, _, data| subscribe('sql.active_record') do |_, start, finish, _, data|
if RequestStore.active? && RequestStore.store[:peek_enabled] if RequestStore.active? && RequestStore.store[:peek_enabled]
# data[:cached] is only available starting from Rails 5.1.0
# https://github.com/rails/rails/blob/v5.1.0/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb#L113
# Before that, data[:name] was set to 'CACHE'
# https://github.com/rails/rails/blob/v4.2.9/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb#L80
unless data.fetch(:cached, data[:name] == 'CACHE')
track_query(data[:sql].strip, data[:binds], start, finish) track_query(data[:sql].strip, data[:binds], start, finish)
end end
end end
end end
end
def track_query(raw_query, bindings, start, finish) def track_query(raw_query, bindings, start, finish)
query = Gitlab::Sherlock::Query.new(raw_query, start, finish) query = Gitlab::Sherlock::Query.new(raw_query, start, finish)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment