Skip to content

Commit

Permalink
remove RedisRateLimit error categorization
Browse files Browse the repository at this point in the history
  • Loading branch information
orioldsm committed Sep 9, 2024
1 parent 0d043a4 commit cbc3c06
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 34 deletions.
4 changes: 1 addition & 3 deletions lib/sidekiq/instrument/middleware/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ def call(worker, job, _queue, &block)
Statter.dogstatsd&.increment('sidekiq.enqueue.retry', dd_options)
end

# categorize rate limit lock errors differently from actual errors
error_string = e.class.name.eql?("RedisRateLimit::Throttle::LockFailedError") ? 'sidekiq.error.redis_rate_lock' : 'sidekiq.error'
Statter.dogstatsd&.increment(error_string, dd_options)
Statter.dogstatsd&.increment('sidekiq.error', dd_options)
Statter.statsd.increment(metric_name(worker, 'error'))

raise e
Expand Down
31 changes: 0 additions & 31 deletions spec/sidekiq-instrument/server_middleware_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -235,37 +235,6 @@
end
end

context 'when the error is RedisRateLimit::Throttle::LockFailedError' do
let(:expected_lock_error_dog_options) { { tags: ['queue:default', 'worker:my_worker', 'error:RedisRateLimit::Throttle::LockFailedError'] } }
let(:lock_error) { RuntimeError.new('foo') }

before do
# force the error's class name to be the RedisRateLimit error type string
# it's an external error class and we can't actually create an instance of the error
allow(lock_error).to receive_message_chain(:class, :name).and_return("RedisRateLimit::Throttle::LockFailedError")
allow_any_instance_of(MyWorker).to receive(:perform).and_raise(lock_error)
end

it 'increments the DogStatsD sidekiq.error.redis_rate_lock counter' do
expect(
Sidekiq::Instrument::Statter.dogstatsd
).to receive(:increment).with('sidekiq.dequeue', expected_dog_options).once
expect(
Sidekiq::Instrument::Statter.dogstatsd
).not_to receive(:increment).with('sidekiq.enqueue.retry', expected_lock_error_dog_options)
expect(Sidekiq::Instrument::Statter.dogstatsd).not_to receive(:time)
expect(
Sidekiq::Instrument::Statter.dogstatsd
).to receive(:increment).with('sidekiq.error.redis_rate_lock', expected_lock_error_dog_options).once

begin
MyWorker.perform_async
rescue StandardError
nil
end
end
end

it 're-raises the error' do
expect { MyWorker.perform_async }.to raise_error 'foo'
end
Expand Down

0 comments on commit cbc3c06

Please sign in to comment.