Properly set Output Metrics in Output Delegator Strategy.

Fixes https://github.com/elastic/logstash/issues/5810

Fixes #5825
This commit is contained in:
Andrew Cholakian 2016-08-24 14:25:38 -05:00
parent 31392e7fb0
commit 5be74fca22
5 changed files with 8 additions and 2 deletions

View file

@ -4,7 +4,8 @@ module LogStash module OutputDelegatorStrategies class Legacy
def initialize(logger, klass, metric, plugin_args)
@worker_count = (plugin_args["workers"] || 1).to_i
@workers = @worker_count.times.map {|t| klass.new(plugin_args)}
@workers = @worker_count.times.map { klass.new(plugin_args) }
@workers.each {|w| w.metric = metric }
@worker_queue = SizedQueue.new(@worker_count)
@workers.each {|w| @worker_queue << w}
end

View file

@ -1,6 +1,7 @@
module LogStash module OutputDelegatorStrategies class Shared
def initialize(logger, klass, metric, plugin_args)
@output = klass.new(plugin_args)
@output.metric = metric
end
def register

View file

@ -1,6 +1,7 @@
module LogStash module OutputDelegatorStrategies class Single
def initialize(logger, klass, metric, plugin_args)
@output = klass.new(plugin_args)
@output.metric = metric
@mutex = Mutex.new
end

View file

@ -97,6 +97,10 @@ describe LogStash::OutputDelegator do
expect(out_klass).to have_received(:new).with(plugin_args)
end
it "should set the metric on the instance" do
expect(out_inst).to have_received(:metric=).with(metric)
end
[[:register], [:do_close], [:multi_receive, [[]] ] ].each do |method, args|
context "strategy objects" do
before do

View file

@ -34,7 +34,6 @@ class LogStash::Outputs::NOOPMultiReceiveEncoded < ::LogStash::Outputs::Base
end
end
describe "LogStash::Outputs::Base#new" do
let(:params) { {} }
subject(:instance) { klass.new(params.dup) }