Skip to content

Commit

Permalink
Blacklisted queues should not send general metrics
Browse files Browse the repository at this point in the history
When the middleware is called and a blacklisted queue is referenced,
we should short-circuit processing altogether and not even report the
general set of metrics.
  • Loading branch information
Jay Zeschin committed Sep 21, 2015
1 parent 6732198 commit 28857b4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 15 deletions.
2 changes: 1 addition & 1 deletion lib/librato-sidekiq/middleware.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ def call(worker_instance, msg, queue, redis_pool = nil)
private

def track(tracking_group, stats, worker_instance, msg, queue, elapsed)
submit_general_stats tracking_group, stats
return unless allowed_to_submit queue, worker_instance
submit_general_stats tracking_group, stats
# puts "doing Librato insert"
tracking_group.group queue.to_s do |q|
q.increment 'processed'
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

0 comments on commit 28857b4

Please sign in to comment.