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
diff options
context:
space:
mode:
Diffstat (limited to 'lib/peek/views/click_house.rb')
-rw-r--r--lib/peek/views/click_house.rb50
1 files changed, 50 insertions, 0 deletions
diff --git a/lib/peek/views/click_house.rb b/lib/peek/views/click_house.rb
new file mode 100644
index 00000000000..cc109ccea51
--- /dev/null
+++ b/lib/peek/views/click_house.rb
@@ -0,0 +1,50 @@
+# frozen_string_literal: true
+
+module Peek
+ module Views
+ class ClickHouse < DetailedView
+ DEFAULT_THRESHOLDS = {
+ calls: 5,
+ duration: 1000,
+ individual_call: 1000
+ }.freeze
+
+ THRESHOLDS = {
+ production: {
+ calls: 5,
+ duration: 1000,
+ individual_call: 1000
+ }
+ }.freeze
+
+ def key
+ 'ch'
+ end
+
+ def self.thresholds
+ @thresholds ||= THRESHOLDS.fetch(Rails.env.to_sym, DEFAULT_THRESHOLDS)
+ end
+
+ private
+
+ def setup_subscribers
+ super
+
+ subscribe('sql.click_house') do |_, start, finish, _, data|
+ detail_store << generate_detail(start, finish, data) if Gitlab::PerformanceBar.enabled_for_request?
+ end
+ end
+
+ def generate_detail(start, finish, data)
+ {
+ start: start,
+ duration: finish - start,
+ sql: data[:query].strip,
+ backtrace: Gitlab::BacktraceCleaner.clean_backtrace(caller),
+ database: "database: #{data[:database]}",
+ statistics: "query stats: #{data[:statistics]}"
+ }
+ end
+ end
+ end
+end