Commit aea9108a authored by Stan Hu's avatar Stan Hu

Log update delay and download times of repository sync

parent 44793b28
......@@ -85,5 +85,11 @@ module Geo
def type
self.class.type
end
def update_delay(finish_time)
return unless project.last_repository_updated_at
(finish_time.to_f - project.last_repository_updated_at.to_f).round(3)
end
end
end
......@@ -11,13 +11,18 @@ module Geo
def fetch_project_repository
log_info('Fetching project repository')
update_registry(started_at: DateTime.now)
start_time = DateTime.now
update_registry(started_at: start_time)
begin
project.ensure_repository
project.repository.fetch_geo_mirror(ssh_url_to_repo)
update_registry(finished_at: DateTime.now)
finish_time = DateTime.now
log_info("Finished repository sync",
update_delay_s: update_delay(finish_time),
download_time_s: (finish_time - start_time).to_f.round(3))
update_registry(finished_at: finish_time)
rescue Gitlab::Shell::Error, Geo::EmptyCloneUrlPrefixError => e
log_error('Error syncing repository', e)
rescue Gitlab::Git::Repository::NoRepository => e
......
......@@ -10,12 +10,17 @@ module Geo
def fetch_wiki_repository
log_info('Fetching wiki repository')
update_registry(started_at: DateTime.now)
start_time = DateTime.now
update_registry(started_at: start_time)
begin
project.wiki.ensure_repository
project.wiki.repository.fetch_geo_mirror(ssh_url_to_wiki)
finish_time = DateTime.now
log_info("Finished wiki sync",
update_delay_s: update_delay(finish_time),
download_time_s: (finish_time - start_time).to_f.round(3))
update_registry(finished_at: DateTime.now)
rescue Gitlab::Git::Repository::NoRepository,
Gitlab::Shell::Error,
......
module Gitlab
module Geo
module ProjectLogHelpers
def log_info(message)
def log_info(message, details = {})
data = base_log_data(message)
data.merge!(details) if details
Gitlab::Geo::Logger.info(data)
end
......
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