Class: Gitlab::Import::Metrics

Inherits:
Object
  • Object
show all
Includes:
Utils::UsageData
Defined in:
lib/gitlab/import/metrics.rb

Constant Summary collapse

IMPORT_DURATION_BUCKETS =
[0.5, 1, 3, 5, 10, 60, 120, 240, 360, 720, 1440].freeze

Constants included from Utils::UsageData

Utils::UsageData::DISTRIBUTED_HLL_FALLBACK, Utils::UsageData::FALLBACK, Utils::UsageData::HISTOGRAM_FALLBACK, Utils::UsageData::MAX_BUCKET_SIZE

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Utils::UsageData

#add, #add_metric, #alt_usage_data, #count, #distinct_count, #epics_deepest_relationship_level, #estimate_batch_distinct_count, #histogram, #jira_integration_data, #maximum_id, #measure_duration, #minimum_id, #redis_usage_data, #sum, #track_usage_event, #with_duration, #with_finished_at, #with_prometheus_client

Methods included from Utils::StrongMemoize

#clear_memoization, #strong_memoize, #strong_memoized?

Constructor Details

#initialize(importer, project) ⇒ Metrics

Returns a new instance of Metrics.


12
13
14
15
# File 'lib/gitlab/import/metrics.rb', line 12

def initialize(importer, project)
  @importer = importer
  @project = project
end

Instance Attribute Details

#durationObject (readonly)

Returns the value of attribute duration.


10
11
12
# File 'lib/gitlab/import/metrics.rb', line 10

def duration
  @duration
end

#importerObject (readonly)

Returns the value of attribute importer.


10
11
12
# File 'lib/gitlab/import/metrics.rb', line 10

def importer
  @importer
end

Instance Method Details

#issues_counterObject


37
38
39
40
41
42
# File 'lib/gitlab/import/metrics.rb', line 37

def issues_counter
  @issues_counter ||= Gitlab::Metrics.counter(
    :"#{importer}_imported_issues_total",
    'The number of imported issues'
  )
end

#merge_requests_counterObject


44
45
46
47
48
49
# File 'lib/gitlab/import/metrics.rb', line 44

def merge_requests_counter
  @merge_requests_counter ||= Gitlab::Metrics.counter(
    :"#{importer}_imported_merge_requests_total",
    'The number of imported merge (pull) requests'
  )
end

#track_failed_importObject


31
32
33
34
35
# File 'lib/gitlab/import/metrics.rb', line 31

def track_failed_import
  return unless project.github_import?

  track_usage_event(:github_import_project_failure, project.id)
end

#track_finished_importObject


23
24
25
26
27
28
29
# File 'lib/gitlab/import/metrics.rb', line 23

def track_finished_import
  @duration = Time.zone.now - project.created_at

  observe_histogram
  projects_counter.increment
  track_finish_metric
end

#track_start_importObject


17
18
19
20
21
# File 'lib/gitlab/import/metrics.rb', line 17

def track_start_import
  return unless project.github_import?

  track_usage_event(:github_import_project_start, project.id)
end