2017-07-10 23:35:47 -04:00
|
|
|
Rails.application.config.peek.adapter = :redis, { client: ::Redis.new(Gitlab::Redis::Cache.params) }
|
2017-05-17 07:20:55 -04:00
|
|
|
|
|
|
|
Peek.into Peek::Views::Host
|
2018-01-11 11:34:01 -05:00
|
|
|
|
2017-06-07 03:57:21 -04:00
|
|
|
if Gitlab::Database.mysql?
|
2017-06-07 13:55:07 -04:00
|
|
|
require 'peek-mysql2'
|
2017-06-07 10:53:13 -04:00
|
|
|
PEEK_DB_CLIENT = ::Mysql2::Client
|
|
|
|
PEEK_DB_VIEW = Peek::Views::Mysql2
|
2018-01-30 13:55:51 -05:00
|
|
|
elsif Gitlab::Database.postgresql?
|
2017-06-07 03:57:21 -04:00
|
|
|
require 'peek-pg'
|
2017-06-07 10:53:13 -04:00
|
|
|
PEEK_DB_CLIENT = ::PG::Connection
|
|
|
|
PEEK_DB_VIEW = Peek::Views::PG
|
2019-05-03 07:31:01 -04:00
|
|
|
|
|
|
|
# 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
|
2018-01-30 13:55:51 -05:00
|
|
|
else
|
|
|
|
raise "Unsupported database adapter for peek!"
|
2017-06-07 03:57:21 -04:00
|
|
|
end
|
2018-01-11 11:34:01 -05:00
|
|
|
|
2017-06-07 13:55:07 -04:00
|
|
|
Peek.into PEEK_DB_VIEW
|
2018-03-08 04:58:24 -05:00
|
|
|
Peek.into Peek::Views::Gitaly
|
|
|
|
Peek.into Peek::Views::Rblineprof
|
2019-07-17 15:33:49 -04:00
|
|
|
Peek.into Peek::Views::RedisDetailed
|
2017-05-17 07:20:55 -04:00
|
|
|
Peek.into Peek::Views::GC
|
2019-02-18 15:57:22 -05:00
|
|
|
Peek.into Peek::Views::Tracing if Labkit::Tracing.tracing_url_enabled?
|
2017-06-01 10:10:17 -04:00
|
|
|
|
2017-09-19 11:25:42 -04:00
|
|
|
# rubocop:disable Naming/ClassAndModuleCamelCase
|
2017-06-07 10:53:13 -04:00
|
|
|
class PEEK_DB_CLIENT
|
|
|
|
class << self
|
|
|
|
attr_accessor :query_details
|
2017-06-01 10:10:17 -04:00
|
|
|
end
|
2017-06-07 10:53:13 -04:00
|
|
|
self.query_details = Concurrent::Array.new
|
2017-06-01 10:10:17 -04:00
|
|
|
end
|
2017-06-07 10:53:13 -04:00
|
|
|
|
|
|
|
PEEK_DB_VIEW.prepend ::Gitlab::PerformanceBar::PeekQueryTracker
|
2019-07-03 10:02:03 -04:00
|
|
|
|
|
|
|
require 'peek/adapters/redis'
|
|
|
|
Peek::Adapters::Redis.prepend ::Gitlab::PerformanceBar::RedisAdapterWhenPeekEnabled
|