diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 65d46e7489d..78e2254c665 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1395,7 +1395,6 @@ spec/sidekiq/mhv/account_creator_job_spec.rb @department-of-veterans-affairs/oct spec/sidekiq/pager_duty @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group spec/sidekiq/preneeds @department-of-veterans-affairs/mbs-core-team @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group spec/sidekiq/schema_contract @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group -spec/sidekiq/sidekiq_stats_job_spec.rb @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group spec/sidekiq/sign_in @department-of-veterans-affairs/octo-identity spec/sidekiq/sign_in/delete_expired_sessions_job_spec.rb @department-of-veterans-affairs/octo-identity spec/sidekiq/simple_forms_api @department-of-veterans-affairs/platform-va-product-forms @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group diff --git a/app/sidekiq/sidekiq_stats_job.rb b/app/sidekiq/sidekiq_stats_job.rb deleted file mode 100644 index d60d088d1df..00000000000 --- a/app/sidekiq/sidekiq_stats_job.rb +++ /dev/null @@ -1,33 +0,0 @@ -# frozen_string_literal: true - -class SidekiqStatsJob - include Sidekiq::Job - - sidekiq_options queue: 'critical' - - METRIC_NAMES = %w[ - processed - failed - scheduled_size - ].freeze - - def perform - info = Sidekiq::Stats.new - - self.class::METRIC_NAMES.each do |method, stat| - stat ||= method - - StatsD.gauge "shared.sidekiq.stats.#{stat}", info.send(method) - end - - working = Sidekiq::ProcessSet.new.select { |p| p[:busy] == 1 }.count - StatsD.gauge 'shared.sidekiq.stats.working', working - - retry_size = Sidekiq::RetrySet.new.size - StatsD.gauge 'shared.sidekiq.stats.retry_size', retry_size - - info.queues.each do |name, size| - StatsD.gauge "shared.sidekiq.#{name}.size", size - end - end -end diff --git a/spec/sidekiq/sidekiq_stats_job_spec.rb b/spec/sidekiq/sidekiq_stats_job_spec.rb deleted file mode 100644 index 38b74937f72..00000000000 --- a/spec/sidekiq/sidekiq_stats_job_spec.rb +++ /dev/null @@ -1,45 +0,0 @@ -# frozen_string_literal: true - -require 'rails_helper' -require 'sidekiq/api' - -RSpec.describe SidekiqStatsJob, type: :job do - subject do - described_class.new - end - - describe '#perform' do - before do - # this method calls gauge multiple times, allow the ones we aren't testing - allow(StatsD).to receive(:gauge) - end - - context 'for METRIC_NAMES' do - SidekiqStatsJob::METRIC_NAMES.each do |metric| - metric_key = "shared.sidekiq.stats.#{metric}" - it "sends statsd a gauge of the info to #{metric_key}" do - stat = [1, 3, 7, 11].sample - expect_any_instance_of(Sidekiq::Stats).to receive(metric).and_return(stat) - expect(StatsD).to receive(:gauge).with(metric_key, stat) - subject.perform - end - end - end - - it 'gauges number of working jobs' do - busy_process_set = [1, 2, 3] - allow_any_instance_of(Sidekiq::ProcessSet).to receive(:select).and_return(busy_process_set) - expect(StatsD).to receive(:gauge).with('shared.sidekiq.stats.working', busy_process_set.count) - subject.perform - end - - it 'gauges the size of each queue' do - queues = { 'queue1' => 4, 'queue2' => 44 } - allow_any_instance_of(Sidekiq::Stats).to receive(:queues).and_return(queues) - queues.each do |name, size| - expect(StatsD).to receive(:gauge).with("shared.sidekiq.#{name}.size", size) - end - subject.perform - end - end -end