Generate codec IDs randomly

Fixes #7930
This commit is contained in:
Andrew Cholakian 2017-08-08 13:20:13 -05:00
parent 2844a179cf
commit e8a1164b2f
2 changed files with 13 additions and 7 deletions

View file

@ -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

View file

@ -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