mirror of
https://github.com/elastic/logstash.git
synced 2025-04-23 22:27:21 -04:00
Make sure the name
of the plugin is saved in the metric store
Fixes: #5799 Fixes #5800
This commit is contained in:
parent
688adca814
commit
3f4190e7f4
3 changed files with 25 additions and 4 deletions
|
@ -15,12 +15,12 @@ module LogStash class OutputDelegator
|
|||
@strategy_registry = strategy_registry
|
||||
raise ArgumentError, "No strategy registry specified" unless strategy_registry
|
||||
raise ArgumentError, "No ID specified! Got args #{plugin_args}" unless id
|
||||
|
||||
|
||||
build_strategy!
|
||||
|
||||
@namespaced_metric = metric.namespace(id.to_sym)
|
||||
@namespaced_metric.gauge(:name, config_name)
|
||||
@metric_events = @namespaced_metric.namespace(:events)
|
||||
@namespaced_metric.gauge(:name, id)
|
||||
end
|
||||
|
||||
def config_name
|
||||
|
|
|
@ -6,8 +6,9 @@ describe LogStash::OutputDelegator do
|
|||
let(:logger) { double("logger") }
|
||||
let(:events) { 7.times.map { LogStash::Event.new }}
|
||||
let(:plugin_args) { {"id" => "foo", "arg1" => "val1"} }
|
||||
let(:metric) { LogStash::Instrument::NullMetric.new }
|
||||
|
||||
subject { described_class.new(logger, out_klass, LogStash::Instrument::NullMetric.new, ::LogStash::OutputDelegatorStrategyRegistry.instance, plugin_args) }
|
||||
subject { described_class.new(logger, out_klass, metric, ::LogStash::OutputDelegatorStrategyRegistry.instance, plugin_args) }
|
||||
|
||||
context "with a plain output plugin" do
|
||||
let(:out_klass) { double("output klass") }
|
||||
|
@ -15,10 +16,13 @@ describe LogStash::OutputDelegator do
|
|||
let(:concurrency) { :single }
|
||||
|
||||
before(:each) do
|
||||
# use the same metric instance
|
||||
allow(metric).to receive(:namespace).with(any_args).and_return(metric)
|
||||
|
||||
allow(out_klass).to receive(:new).with(any_args).and_return(out_inst)
|
||||
allow(out_klass).to receive(:name).and_return("example")
|
||||
allow(out_klass).to receive(:concurrency).with(any_args).and_return concurrency
|
||||
allow(out_klass).to receive(:config_name)
|
||||
allow(out_klass).to receive(:config_name).and_return("dummy_plugin")
|
||||
allow(out_inst).to receive(:register)
|
||||
allow(out_inst).to receive(:multi_receive)
|
||||
allow(out_inst).to receive(:metric=).with(any_args)
|
||||
|
@ -32,6 +36,11 @@ describe LogStash::OutputDelegator do
|
|||
expect { subject }.not_to raise_error
|
||||
end
|
||||
|
||||
it "should push the name of the plugin to the metric" do
|
||||
expect(metric).to receive(:gauge).with(:name, out_klass.config_name)
|
||||
described_class.new(logger, out_klass, metric, ::LogStash::OutputDelegatorStrategyRegistry.instance, plugin_args)
|
||||
end
|
||||
|
||||
context "after having received a batch of events" do
|
||||
before do
|
||||
subject.register
|
||||
|
|
|
@ -641,6 +641,18 @@ describe LogStash::Pipeline do
|
|||
plugin_name = dummy_output_id.to_sym
|
||||
expect(collected_metric[:stats][:pipelines][:main][:plugins][:outputs][plugin_name][:events][:out].value).to eq(number_of_events)
|
||||
end
|
||||
|
||||
it "populates the name of the output plugin" do
|
||||
plugin_name = dummy_output_id.to_sym
|
||||
expect(collected_metric[:stats][:pipelines][:main][:plugins][:outputs][plugin_name][:name].value).to eq(DummyOutput.config_name)
|
||||
end
|
||||
|
||||
it "populates the name of the filter plugin" do
|
||||
[multiline_id, multiline_id_other].map(&:to_sym).each do |id|
|
||||
plugin_name = "multiline_#{id}".to_sym
|
||||
expect(collected_metric[:stats][:pipelines][:main][:plugins][:filters][plugin_name][:name].value).to eq(LogStash::Filters::Multiline.config_name)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue