mirror of
https://github.com/elastic/logstash.git
synced 2025-04-23 22:27:21 -04:00
Properly set Output Metrics in Output Delegator Strategy.
Fixes https://github.com/elastic/logstash/issues/5810 Fixes #5825
This commit is contained in:
parent
31392e7fb0
commit
5be74fca22
5 changed files with 8 additions and 2 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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) }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue