Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/config
diff options
context:
space:
mode:
authorSean McGivern <sean@gitlab.com>2019-07-26 16:03:00 +0300
committerSean McGivern <sean@gitlab.com>2019-07-26 16:37:26 +0300
commitad1c71663f7780838c7c90979419f3e3cf5ec580 (patch)
tree59443b9ea0f860511610acf181e1eadbc8c88d34 /config
parent55f99e930e1c147ec191a234ff4881ea7e70ea61 (diff)
Replace peek-pg with our own implementation
This uses an ActiveRecord subscriber to get queries and calculate the total query time from that. This means that the total will always be consistent with the queries in the table. It does however mean that we could potentially miss some queries that don't go through ActiveRecord. Making this change also allows us to unify the response JSON a little bit, making the frontend slightly simpler as a result.
Diffstat (limited to 'config')
-rw-r--r--config/initializers/peek.rb40
1 files changed, 5 insertions, 35 deletions
diff --git a/config/initializers/peek.rb b/config/initializers/peek.rb
index 8416ae430c7..d51d553c939 100644
--- a/config/initializers/peek.rb
+++ b/config/initializers/peek.rb
@@ -1,44 +1,14 @@
-Rails.application.config.peek.adapter = :redis, { client: ::Redis.new(Gitlab::Redis::Cache.params) }
-
-Peek.into Peek::Views::Host
+require 'peek/adapters/redis'
-if Gitlab::Database.postgresql?
- require 'peek-pg'
- PEEK_DB_CLIENT = ::PG::Connection
- PEEK_DB_VIEW = Peek::Views::PG
+Peek::Adapters::Redis.prepend ::Gitlab::PerformanceBar::RedisAdapterWhenPeekEnabled
- # 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
+Rails.application.config.peek.adapter = :redis, { client: ::Redis.new(Gitlab::Redis::Cache.params) }
-Peek.into PEEK_DB_VIEW
+Peek.into Peek::Views::Host
+Peek.into Peek::Views::ActiveRecord
Peek.into Peek::Views::Gitaly
Peek.into Peek::Views::Rblineprof
Peek.into Peek::Views::RedisDetailed
Peek.into Peek::Views::Rugged
Peek.into Peek::Views::GC
Peek.into Peek::Views::Tracing if Labkit::Tracing.tracing_url_enabled?
-
-# rubocop:disable Naming/ClassAndModuleCamelCase
-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
-
-require 'peek/adapters/redis'
-Peek::Adapters::Redis.prepend ::Gitlab::PerformanceBar::RedisAdapterWhenPeekEnabled