Class: Gitlab::DatabaseImporters::CommonMetrics::Importer

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/database_importers/common_metrics/importer.rb

Constant Summary collapse

MissingQueryId =
Class.new(StandardError)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filename = 'common_metrics.yml') ⇒ Importer

Returns a new instance of Importer.


11
12
13
# File 'lib/gitlab/database_importers/common_metrics/importer.rb', line 11

def initialize(filename = 'common_metrics.yml')
  @content = YAML.load_file(Rails.root.join('config', 'prometheus', filename))
end

Instance Attribute Details

#contentObject (readonly)

Returns the value of attribute content


9
10
11
# File 'lib/gitlab/database_importers/common_metrics/importer.rb', line 9

def content
  @content
end

Instance Method Details

#executeObject


15
16
17
18
19
20
21
22
# File 'lib/gitlab/database_importers/common_metrics/importer.rb', line 15

def execute
  CommonMetrics::PrometheusMetric.reset_column_information

  process_content do |id, attributes|
    find_or_build_metric!(id)
      .update!(**attributes)
  end
end