Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

avoid variable collision in pipeline stats api #11059

Merged
merged 1 commit into from Aug 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions logstash-core/lib/logstash/api/commands/stats.rb
Expand Up @@ -65,8 +65,8 @@ def pipeline(pipeline_id = nil, opts={})
service.agent,
service.snapshot.metric_store,
true).each_with_object({}) do |pipeline_stats, memo|
pipeline_id = pipeline_stats["id"].to_s
memo[pipeline_id] = pipeline_stats
p_id = pipeline_stats["id"].to_s
memo[p_id] = pipeline_stats
end

if pipeline_id.nil?
Expand Down
14 changes: 11 additions & 3 deletions logstash-core/spec/logstash/api/commands/stats_spec.rb
Expand Up @@ -143,8 +143,16 @@
)
end
end
context "when using multiple pipelines" do
before(:each) do
expect(LogStash::Config::PipelinesInfo).to receive(:format_pipelines_info).and_return([
{"id" => :main},
{"id" => :secondary},
])
end
it "contains metrics for all pipelines" do
expect(report.keys).to include(:main, :secondary)
end
end
end



end
5 changes: 4 additions & 1 deletion logstash-core/spec/support/shared_contexts.rb
Expand Up @@ -24,9 +24,12 @@
settings.set("config.reload.automatic", false)
@agent = make_test_agent(settings)
@agent.execute
@pipelines_registry = LogStash::PipelinesRegistry.new
pipeline_config = mock_pipeline_config(:main, "input { generator { id => '123' } } output { null {} }")
pipeline_creator = LogStash::PipelineAction::Create.new(pipeline_config, @agent.metric)
@pipelines_registry = LogStash::PipelinesRegistry.new
expect(pipeline_creator.execute(@agent, @pipelines_registry)).to be_truthy
pipeline_config = mock_pipeline_config(:secondary, "input { generator { id => '123' } } output { null {} }")
pipeline_creator = LogStash::PipelineAction::Create.new(pipeline_config, @agent.metric)
expect(pipeline_creator.execute(@agent, @pipelines_registry)).to be_truthy
end

Expand Down