diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-23 12:14:52 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-23 12:14:52 +0300 |
commit | 347bf09d6ecf4871da234c06ca8ee541e27b5105 (patch) | |
tree | 2ad6943e0c681c22acc8850d1debc6a983b0e006 /app/workers | |
parent | 0a51be0866d33273070f535257626a9eb2e10700 (diff) |
Add latest changes from gitlab-org/gitlab@13-10-stable-eev13.10.0-rc20210223090520
Diffstat (limited to 'app/workers')
-rw-r--r-- | app/workers/all_queues.yml | 32 | ||||
-rw-r--r-- | app/workers/analytics/instance_statistics/count_job_trigger_worker.rb | 18 | ||||
-rw-r--r-- | app/workers/analytics/instance_statistics/counter_job_worker.rb | 22 | ||||
-rw-r--r-- | app/workers/analytics/usage_trends/count_job_trigger_worker.rb | 34 | ||||
-rw-r--r-- | app/workers/analytics/usage_trends/counter_job_worker.rb | 35 | ||||
-rw-r--r-- | app/workers/post_receive.rb | 1 | ||||
-rw-r--r-- | app/workers/releases/create_evidence_worker.rb | 1 |
7 files changed, 101 insertions, 42 deletions
diff --git a/app/workers/all_queues.yml b/app/workers/all_queues.yml index 59ab0a4d05b..b8481382577 100644 --- a/app/workers/all_queues.yml +++ b/app/workers/all_queues.yml @@ -131,6 +131,14 @@ :weight: 1 :idempotent: true :tags: [] +- :name: cronjob:analytics_usage_trends_count_job_trigger + :feature_category: :devops_reports + :has_external_dependencies: + :urgency: :low + :resource_boundary: :unknown + :weight: 1 + :idempotent: true + :tags: [] - :name: cronjob:authorized_project_update_periodic_recalculate :feature_category: :source_code_management :has_external_dependencies: @@ -347,14 +355,6 @@ :weight: 1 :idempotent: :tags: [] -- :name: cronjob:releases_create_evidence - :feature_category: :release_evidence - :has_external_dependencies: - :urgency: :low - :resource_boundary: :unknown - :weight: 1 - :idempotent: - :tags: [] - :name: cronjob:releases_manage_evidence :feature_category: :release_evidence :has_external_dependencies: @@ -1413,6 +1413,14 @@ :weight: 1 :idempotent: true :tags: [] +- :name: analytics_usage_trends_counter_job + :feature_category: :devops_reports + :has_external_dependencies: + :urgency: :low + :resource_boundary: :unknown + :weight: 1 + :idempotent: true + :tags: [] - :name: approve_blocked_pending_approval_users :feature_category: :users :has_external_dependencies: @@ -2084,6 +2092,14 @@ :weight: 2 :idempotent: :tags: [] +- :name: releases_create_evidence + :feature_category: :release_evidence + :has_external_dependencies: + :urgency: :low + :resource_boundary: :unknown + :weight: 1 + :idempotent: + :tags: [] - :name: remote_mirror_notification :feature_category: :source_code_management :has_external_dependencies: diff --git a/app/workers/analytics/instance_statistics/count_job_trigger_worker.rb b/app/workers/analytics/instance_statistics/count_job_trigger_worker.rb index 81a765d5d08..3ec92bc7635 100644 --- a/app/workers/analytics/instance_statistics/count_job_trigger_worker.rb +++ b/app/workers/analytics/instance_statistics/count_job_trigger_worker.rb @@ -2,31 +2,19 @@ module Analytics module InstanceStatistics + # This worker will be removed in 14.0 class CountJobTriggerWorker include ApplicationWorker include CronjobQueue # rubocop:disable Scalability/CronWorkerContext - DEFAULT_DELAY = 3.minutes.freeze - feature_category :devops_reports urgency :low idempotent! def perform - recorded_at = Time.zone.now - - worker_arguments = Gitlab::Analytics::InstanceStatistics::WorkersArgumentBuilder.new( - measurement_identifiers: ::Analytics::InstanceStatistics::Measurement.measurement_identifier_values, - recorded_at: recorded_at - ).execute - - perform_in = DEFAULT_DELAY.minutes.from_now - worker_arguments.each do |args| - CounterJobWorker.perform_in(perform_in, *args) - - perform_in += DEFAULT_DELAY - end + # Delegate to the new worker + Analytics::UsageTrends::CountJobTriggerWorker.new.perform end end end diff --git a/app/workers/analytics/instance_statistics/counter_job_worker.rb b/app/workers/analytics/instance_statistics/counter_job_worker.rb index c07b2569453..4beed8a3e2f 100644 --- a/app/workers/analytics/instance_statistics/counter_job_worker.rb +++ b/app/workers/analytics/instance_statistics/counter_job_worker.rb @@ -2,6 +2,7 @@ module Analytics module InstanceStatistics + # This worker will be removed in 14.0 class CounterJobWorker include ApplicationWorker @@ -10,24 +11,9 @@ module Analytics idempotent! - def perform(measurement_identifier, min_id, max_id, recorded_at) - query_scope = ::Analytics::InstanceStatistics::Measurement.identifier_query_mapping[measurement_identifier].call - - count = if min_id.nil? || max_id.nil? # table is empty - 0 - else - counter(query_scope, min_id, max_id) - end - - return if count == Gitlab::Database::BatchCounter::FALLBACK - - InstanceStatistics::Measurement.insert_all([{ recorded_at: recorded_at, count: count, identifier: measurement_identifier }]) - end - - private - - def counter(query_scope, min_id, max_id) - Gitlab::Database::BatchCount.batch_count(query_scope, start: min_id, finish: max_id) + def perform(*args) + # Delegate to the new worker + Analytics::UsageTrends::CounterJobWorker.new.perform(*args) end end end diff --git a/app/workers/analytics/usage_trends/count_job_trigger_worker.rb b/app/workers/analytics/usage_trends/count_job_trigger_worker.rb new file mode 100644 index 00000000000..37f5c19d64c --- /dev/null +++ b/app/workers/analytics/usage_trends/count_job_trigger_worker.rb @@ -0,0 +1,34 @@ +# frozen_string_literal: true + +module Analytics + module UsageTrends + class CountJobTriggerWorker + extend ::Gitlab::Utils::Override + include ApplicationWorker + include CronjobQueue # rubocop:disable Scalability/CronWorkerContext + + DEFAULT_DELAY = 3.minutes.freeze + + feature_category :devops_reports + urgency :low + + idempotent! + + def perform + recorded_at = Time.zone.now + + worker_arguments = Gitlab::Analytics::UsageTrends::WorkersArgumentBuilder.new( + measurement_identifiers: ::Analytics::UsageTrends::Measurement.measurement_identifier_values, + recorded_at: recorded_at + ).execute + + perform_in = DEFAULT_DELAY.minutes.from_now + worker_arguments.each do |args| + CounterJobWorker.perform_in(perform_in, *args) + + perform_in += DEFAULT_DELAY + end + end + end + end +end diff --git a/app/workers/analytics/usage_trends/counter_job_worker.rb b/app/workers/analytics/usage_trends/counter_job_worker.rb new file mode 100644 index 00000000000..275c6ac2de2 --- /dev/null +++ b/app/workers/analytics/usage_trends/counter_job_worker.rb @@ -0,0 +1,35 @@ +# frozen_string_literal: true + +module Analytics + module UsageTrends + class CounterJobWorker + extend ::Gitlab::Utils::Override + include ApplicationWorker + + feature_category :devops_reports + urgency :low + + idempotent! + + def perform(measurement_identifier, min_id, max_id, recorded_at) + query_scope = ::Analytics::UsageTrends::Measurement.identifier_query_mapping[measurement_identifier].call + + count = if min_id.nil? || max_id.nil? # table is empty + 0 + else + counter(query_scope, min_id, max_id) + end + + return if count == Gitlab::Database::BatchCounter::FALLBACK + + UsageTrends::Measurement.insert_all([{ recorded_at: recorded_at, count: count, identifier: measurement_identifier }]) + end + + private + + def counter(query_scope, min_id, max_id) + Gitlab::Database::BatchCount.batch_count(query_scope, start: min_id, finish: max_id) + end + end + end +end diff --git a/app/workers/post_receive.rb b/app/workers/post_receive.rb index ac55f883fc5..313b901c08e 100644 --- a/app/workers/post_receive.rb +++ b/app/workers/post_receive.rb @@ -123,6 +123,7 @@ class PostReceive # rubocop:disable Scalability/IdempotentWorker def after_project_changes_hooks(project, user, refs, changes) experiment(:new_project_readme, actor: user).track_initial_writes(project) + experiment(:empty_repo_upload, project: project).track(:initial_write) if project.empty_repo? repository_update_hook_data = Gitlab::DataBuilder::Repository.update(project, user, changes, refs) SystemHooksService.new.execute_hooks(repository_update_hook_data, :repository_update_hooks) Gitlab::UsageDataCounters::SourceCodeCounter.count(:pushes) diff --git a/app/workers/releases/create_evidence_worker.rb b/app/workers/releases/create_evidence_worker.rb index db75fae1639..d22329216f9 100644 --- a/app/workers/releases/create_evidence_worker.rb +++ b/app/workers/releases/create_evidence_worker.rb @@ -3,7 +3,6 @@ module Releases class CreateEvidenceWorker # rubocop:disable Scalability/IdempotentWorker include ApplicationWorker - include CronjobQueue # rubocop:disable Scalability/CronWorkerContext feature_category :release_evidence |