Class: GitLab::Exporter::Database::ZoektCollector

Inherits:
Base
  • Object
show all
Defined in:
lib/gitlab_exporter/database/zoekt.rb

Overview

A helper class to collect zoekt metrics.

Constant Summary collapse

QUERY =
<<~SQL.freeze
  WITH task_counts AS (
    SELECT 
      zoekt_node_id,
      COUNT(*) AS count
    FROM 
      zoekt_tasks
    WHERE 
      perform_at <= $1
      AND state IN (0, 1)
    GROUP BY 
      zoekt_node_id
  )
  SELECT 
    n.id AS node_id,
    n.metadata ->> 'name' AS node_name,
    COALESCE(tc.count, 0) AS task_count
  FROM 
    zoekt_nodes n
  LEFT JOIN 
    task_counts tc ON n.id = tc.zoekt_node_id
SQL
ZOEKT_ENABLED_QUERY =
<<~SQL.freeze
  SELECT
    zoekt_settings ->> 'zoekt_indexing_enabled' AS zoekt_indexing_enabled 
  FROM application_settings
  ORDER BY ID DESC
  LIMIT 1
SQL

Constants inherited from Base

Base::POOL_SIZE, Base::POOL_TIMEOUT

Instance Method Summary collapse

Methods inherited from Base

configure_type_map_for_results, connection_pool, #connection_pool, #initialize, #with_connection_pool

Constructor Details

This class inherits a constructor from GitLab::Exporter::Database::Base

Instance Method Details

#runObject



37
38
39
40
41
# File 'lib/gitlab_exporter/database/zoekt.rb', line 37

def run
  return unless zoekt_indexing_enabled?

  execute(QUERY, [Time.now.utc])
end