diff --git a/logstash-core/lib/logstash/pipeline.rb b/logstash-core/lib/logstash/pipeline.rb index 8e2ef2653..e23b40742 100644 --- a/logstash-core/lib/logstash/pipeline.rb +++ b/logstash-core/lib/logstash/pipeline.rb @@ -113,12 +113,16 @@ module LogStash; class BasePipeline # Collapse the array of arguments into a single merged hash args = args.reduce({}, &:merge) - # Pull the ID from LIR to keep IDs consistent between the two representations - id = lir.graph.vertices.filter do |v| - v.source_with_metadata && - v.source_with_metadata.line == line && - v.source_with_metadata.column == column - end.findFirst.get.id + if plugin_type == "codec" + id = SecureRandom.uuid # codecs don't really use their IDs for metrics, so we can use anything here + else + # Pull the ID from LIR to keep IDs consistent between the two representations + id = lir.graph.vertices.filter do |v| + v.source_with_metadata && + v.source_with_metadata.line == line && + v.source_with_metadata.column == column + end.findFirst.get.id + end args["id"] = id # some code pulls the id out of the args diff --git a/logstash-core/spec/logstash/pipeline_spec.rb b/logstash-core/spec/logstash/pipeline_spec.rb index c7fdc033d..8d3212ae9 100644 --- a/logstash-core/spec/logstash/pipeline_spec.rb +++ b/logstash-core/spec/logstash/pipeline_spec.rb @@ -41,6 +41,8 @@ class DummyCodec < LogStash::Codecs::Base config_name "dummycodec" milestone 2 + config :format, :validate => :string + def decode(data) data end @@ -373,7 +375,7 @@ describe LogStash::Pipeline do allow(LogStash::Plugin).to receive(:lookup).with("output", "dummyoutput").and_return(::LogStash::Outputs::DummyOutput) end - let(:config) { "input { dummyinput {} } filter { dummyfilter {} } output { dummyoutput {} }"} + let(:config) { "input { dummyinput { codec => plain { format => 'something' } } } filter { dummyfilter {} } output { dummyoutput {} }"} let(:pipeline) { mock_pipeline_from_string(config) } after do