Commit 3ad480c5 authored by alinamihaila's avatar alinamihaila

Skip usage ping generating in GitlabUsagePingWorker for GitLab.com

parent b0d8e619
......@@ -17,9 +17,6 @@ class SubmitUsagePingService
SubmissionError = Class.new(StandardError)
def execute
# Disable usage ping for GitLab.com
# See https://gitlab.com/gitlab-org/gitlab/-/issues/292929 for details
return if Gitlab.com?
return unless Gitlab::CurrentSettings.usage_ping_enabled?
return if User.single_user&.requires_usage_stats_consent?
......
......@@ -13,6 +13,10 @@ class GitlabUsagePingWorker # rubocop:disable Scalability/IdempotentWorker
sidekiq_retry_in { |count| (count + 1) * 8.hours.to_i }
def perform
# Disable usage ping for GitLab.com
# See https://gitlab.com/gitlab-org/gitlab/-/issues/292929 for details
return if Gitlab.com?
# Multiple Sidekiq workers could run this. We should only do this at most once a day.
in_lock(LEASE_KEY, ttl: LEASE_TIMEOUT) do
# Splay the request over a minute to avoid thundering herd problems.
......
......@@ -80,14 +80,6 @@ RSpec.describe SubmitUsagePingService do
end
end
context 'when GitLab.com' do
before do
allow(Gitlab).to receive(:com?).and_return(true)
end
it_behaves_like 'does not run'
end
context 'when usage ping is disabled' do
before do
stub_application_setting(usage_ping_enabled: false)
......
......@@ -8,6 +8,13 @@ RSpec.describe GitlabUsagePingWorker, :clean_gitlab_redis_shared_state do
allow(subject).to receive(:sleep)
end
it 'does not run for GitLab.com' do
allow(Gitlab).to receive(:com?).and_return(true)
expect(SubmitUsagePingService).not_to receive(:new)
subject.perform
end
it 'delegates to SubmitUsagePingService' do
expect_next_instance_of(SubmitUsagePingService) { |service| expect(service).to receive(:execute) }
......
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