From 28857b461de4cb5218c069cdc1319e21534fe25d Mon Sep 17 00:00:00 2001 From: Jay Zeschin Date: Mon, 21 Sep 2015 12:17:02 -0600 Subject: [PATCH] Blacklisted queues should not send general metrics 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. --- lib/librato-sidekiq/middleware.rb | 2 +- spec/unit/middleware_spec.rb | 16 ++-------------- 2 files changed, 3 insertions(+), 15 deletions(-) diff --git a/lib/librato-sidekiq/middleware.rb b/lib/librato-sidekiq/middleware.rb index 2dee0eb..f235efa 100644 --- a/lib/librato-sidekiq/middleware.rb +++ b/lib/librato-sidekiq/middleware.rb @@ -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' diff --git a/spec/unit/middleware_spec.rb b/spec/unit/middleware_spec.rb index f5977a8..cba2590 100644 --- a/spec/unit/middleware_spec.rb +++ b/spec/unit/middleware_spec.rb @@ -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