debian-mirror-gitlab/config/initializers/peek.rb

45 lines
1.2 KiB
Ruby
Raw Normal View History

2017-09-10 17:25:29 +05:30
Rails.application.config.peek.adapter = :redis, { client: ::Redis.new(Gitlab::Redis::Cache.params) }
Peek.into Peek::Views::Host
2018-03-17 18:26:18 +05:30
2017-09-10 17:25:29 +05:30
if Gitlab::Database.mysql?
require 'peek-mysql2'
PEEK_DB_CLIENT = ::Mysql2::Client
PEEK_DB_VIEW = Peek::Views::Mysql2
2018-03-17 18:26:18 +05:30
elsif Gitlab::Database.postgresql?
2017-09-10 17:25:29 +05:30
require 'peek-pg'
PEEK_DB_CLIENT = ::PG::Connection
PEEK_DB_VIEW = Peek::Views::PG
2019-07-31 22:56:46 +05:30
# 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-03-17 18:26:18 +05:30
else
raise "Unsupported database adapter for peek!"
2017-09-10 17:25:29 +05:30
end
2018-03-17 18:26:18 +05:30
2017-09-10 17:25:29 +05:30
Peek.into PEEK_DB_VIEW
2018-05-09 12:01:36 +05:30
Peek.into Peek::Views::Gitaly
Peek.into Peek::Views::Rblineprof
2017-09-10 17:25:29 +05:30
Peek.into Peek::Views::Redis
Peek.into Peek::Views::GC
2019-07-31 22:56:46 +05:30
Peek.into Peek::Views::Tracing if Labkit::Tracing.tracing_url_enabled?
2017-09-10 17:25:29 +05:30
2018-03-17 18:26:18 +05:30
# rubocop:disable Naming/ClassAndModuleCamelCase
2017-09-10 17:25:29 +05:30
class PEEK_DB_CLIENT
class << self
attr_accessor :query_details
end
self.query_details = Concurrent::Array.new
end
PEEK_DB_VIEW.prepend ::Gitlab::PerformanceBar::PeekQueryTracker