Commit bab59bce authored by Douwe Maan's avatar Douwe Maan

Merge branch 'add-events-to-mirrors-and-remote-mirrors' into 'master'

Add event metrics to mirrors and remote mirrors.

See merge request !2744
parents 36a0d7c3 8c4a0ada
......@@ -43,13 +43,13 @@ class RemoteMirror < ActiveRecord::Base
state :failed
after_transition any => :started do |remote_mirror, _|
Gitlab::Mirror.increment_metric(:remote_mirrors_running, 'Remote mirrors running count')
Gitlab::Metrics.add_event(:remote_mirrors_running, path: remote_mirror.project.full_path)
remote_mirror.update(last_update_started_at: Time.now)
end
after_transition started: :finished do |remote_mirror, _|
Gitlab::Mirror.increment_metric(:remote_mirrors_finished, 'Remote mirrors successfully finished count')
Gitlab::Metrics.add_event(:remote_mirrors_finished, path: remote_mirror.project.full_path)
timestamp = Time.now
remote_mirror.update_attributes!(
......@@ -58,7 +58,7 @@ class RemoteMirror < ActiveRecord::Base
end
after_transition started: :failed do |remote_mirror, _|
Gitlab::Mirror.increment_metric(:remote_mirrors_failed, 'Remote mirrors failed count')
Gitlab::Metrics.add_event(:remote_mirrors_failed, path: remote_mirror.project.full_path)
remote_mirror.update(last_update_at: Time.now)
end
......
......@@ -46,8 +46,11 @@ class RepositoryUpdateMirrorWorker
def start_mirror(project)
if project.import_start
Gitlab::Mirror.increment_metric(:mirrors_running, 'Mirrors running count')
Rails.logger.info("Mirror update for #{project.full_path} started. Waiting duration: #{project.mirror_waiting_duration}")
Gitlab::Metrics.add_event_with_values(
:mirrors_running,
{ duration: project.mirror_waiting_duration },
{ path: project.full_path })
true
else
......@@ -60,14 +63,17 @@ class RepositoryUpdateMirrorWorker
error_message = "Mirror update for #{project.full_path} failed with the following message: #{message}"
project.mark_import_as_failed(error_message)
Gitlab::Mirror.increment_metric(:mirrors_failed, 'Mirrors failed count')
Rails.logger.error(error_message)
Gitlab::Metrics.add_event(:mirrors_failed, path: project.full_path)
end
def finish_mirror(project)
project.import_finish
Gitlab::Mirror.increment_metric(:mirrors_finished, 'Mirrors successfully finished count')
Rails.logger.info("Mirror update for #{project.full_path} successfully finished. Update duration: #{project.mirror_update_duration}}.")
Gitlab::Metrics.add_event_with_values(
:mirrors_finished,
{ duration: project.mirror_update_duration },
{ path: project.full_path })
end
end
......@@ -205,7 +205,7 @@ module EE
if import? && !repository_exists?
super
elsif mirror?
::Gitlab::Mirror.increment_metric(:mirrors_scheduled, 'Mirrors scheduled count')
::Gitlab::Metrics.add_event(:mirrors_scheduled, path: full_path)
job_id = RepositoryUpdateMirrorWorker.perform_async(self.id)
log_import_activity(job_id, type: :mirror)
......
......@@ -77,10 +77,6 @@ module Gitlab
current_application_settings.mirror_capacity_threshold
end
def increment_metric(name, docstring)
Gitlab::Metrics.counter(name, docstring).increment
end
private
def update_all_mirrors_cron_job
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment