Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blacklisted queues should not send general metrics #14

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions lib/librato-sidekiq/middleware.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def call(worker_instance, msg, queue, redis_pool = nil)
result = yield
elapsed = (Time.now - start_time).to_f

return result unless enabled
return result unless enabled && allowed_to_submit(queue, worker_instance)
# puts "#{worker_instance} #{queue}"

stats = ::Sidekiq::Stats.new
Expand All @@ -76,7 +76,6 @@ def call(worker_instance, msg, queue, redis_pool = nil)

def track(tracking_group, stats, worker_instance, msg, queue, elapsed)
submit_general_stats tracking_group, stats
return unless allowed_to_submit queue, worker_instance
# puts "doing Librato insert"
tracking_group.group queue.to_s do |q|
q.increment 'processed'
Expand Down
7 changes: 2 additions & 5 deletions spec/unit/client_middleware_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,8 @@
middleware.blacklist_queues << queue_name
end

it { expect { |b| middleware.call(some_worker_instance, some_message, queue_name, &b) }.to yield_with_no_args }

it 'should measure increment queued metric' do
expect(meter).to receive(:increment).with 'queued'
middleware.call(some_worker_instance, some_message, queue_name) {}
it 'should not send any metrics' do
Librato.should_not_receive(:group)
end

end
Expand Down
16 changes: 2 additions & 14 deletions spec/unit/middleware_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,20 +87,8 @@
middleware.blacklist_queues << queue_name
end

it { expect { |b| middleware.call(some_worker_instance, some_message, queue_name, &b) }.to yield_with_no_args }

it 'should measure increment processed metric' do
expect(meter).to receive(:increment).with "processed"
middleware.call(some_worker_instance, some_message, queue_name) {}
end

it 'should measure general metrics' do
{"enqueued" => 1, "failed" => 2, "scheduled" => 3 }.each do |method, stat|
expect(meter).to receive(:measure).with(method.to_s, stat)
end
expect(meter).to receive(:increment).with "processed"

middleware.call(some_worker_instance, some_message, queue_name) {}
it 'should not send any metrics' do
Librato.should_not_receive(:group)
end

end
Expand Down