Class: Gitlab::GithubImport::Stage::FinishImportWorker

Inherits:
Object
  • Object
show all
Includes:
ApplicationWorker, Queue, Gitlab::GithubImport::StageMethods
Defined in:
app/workers/gitlab/github_import/stage/finish_import_worker.rb

Overview

rubocop:disable Scalability/IdempotentWorker

Constant Summary

Constants included from ApplicationWorker

ApplicationWorker::LOGGING_EXTRA_KEY

Constants included from WorkerAttributes

WorkerAttributes::NAMESPACE_WEIGHTS, WorkerAttributes::VALID_RESOURCE_BOUNDARIES, WorkerAttributes::VALID_URGENCIES

Instance Method Summary collapse

Methods included from Gitlab::GithubImport::StageMethods

#find_project, #perform, #try_import

Methods included from SidekiqVersioning::Worker

#job_version

Methods included from WorkerContext

#with_context

Instance Method Details

#counterObject


38
39
40
41
42
43
# File 'app/workers/gitlab/github_import/stage/finish_import_worker.rb', line 38

def counter
  @counter ||= Gitlab::Metrics.counter(
    :github_importer_imported_projects,
    'The number of imported GitHub projects'
  )
end

#histogramObject


31
32
33
34
35
36
# File 'app/workers/gitlab/github_import/stage/finish_import_worker.rb', line 31

def histogram
  @histogram ||= Gitlab::Metrics.histogram(
    :github_importer_total_duration_seconds,
    'Total time spent importing GitHub projects, in seconds'
  )
end

#import(_, project) ⇒ Object

project - An instance of Project.


16
17
18
19
# File 'app/workers/gitlab/github_import/stage/finish_import_worker.rb', line 16

def import(_, project)
  project.after_import
  report_import_time(project)
end

#report_import_time(project) ⇒ Object


21
22
23
24
25
26
27
28
29
# File 'app/workers/gitlab/github_import/stage/finish_import_worker.rb', line 21

def report_import_time(project)
  duration = Time.zone.now - project.created_at
  path = project.full_path

  histogram.observe({ project: path }, duration)
  counter.increment

  logger.info("GitHub importer finished for #{path} in #{duration.round(2)} seconds")
end