diff --git a/VERSION b/VERSION index 4e379d2..bcab45a 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.0.2 +0.0.3 diff --git a/lib/fluent/plugin/filter_flatten.rb b/lib/fluent/plugin/filter_flatten.rb index e8331c6..69100ab 100644 --- a/lib/fluent/plugin/filter_flatten.rb +++ b/lib/fluent/plugin/filter_flatten.rb @@ -29,7 +29,11 @@ def configure(conf) def filter(tag, time, record) begin - flatten(record) if @enabled + if @enabled + flatten(record) + else + record + end rescue => e router.emit_error_event(tag, time, record, e) end diff --git a/spec/filter_flatten_spec.rb b/spec/filter_flatten_spec.rb index 57d6179..163d34c 100644 --- a/spec/filter_flatten_spec.rb +++ b/spec/filter_flatten_spec.rb @@ -33,6 +33,17 @@ def create_filter expect(@filter.flatten({})).to eq Hash.new end + it "no error with disabled" do + @filter.enabled = false + test_hash = {} + test_hash["key"] = "value" + test_hash["key.dot"] = "value.dot" + expect_hash = {} + expect_hash["key"] = "value" + expect_hash["key.dot"] = "value.dot" + expect(@filter.filter("tag", "time", test_hash)).to eq expect_hash + end + it "no error with non recursive hash" do @filter.recurse = false test_hash = {} @@ -41,7 +52,7 @@ def create_filter expect_hash = {} expect_hash["key"] = test_hash["key"] expect_hash["key_dot"] = test_hash["key.dot"] - expect(@filter.flatten(test_hash)).to eq expect_hash + expect(@filter.filter("tag", "time", test_hash)).to eq expect_hash end it "no error with recursive hash with de_dot_nested = false" do @@ -59,7 +70,7 @@ def create_filter expect_hash = {} expect_hash["key"] = "value" expect_hash["child_dot"] = expect_child_hash - expect(@filter.flatten(test_hash)).to eq expect_hash + expect(@filter.filter("tag", "time", test_hash)).to eq expect_hash end it "no error with recursive hash with de_dot_nested = true" do @@ -77,7 +88,7 @@ def create_filter expect_hash = {} expect_hash["key"] = "value" expect_hash["child_dot"] = expect_child_hash - expect(@filter.flatten(test_hash)).to eq expect_hash + expect(@filter.filter("tag", "time", test_hash)).to eq expect_hash end it "no error with recursive array with de_dot_nested = false" do @@ -103,7 +114,7 @@ def create_filter expect_hash = {} expect_hash["key"] = "value" expect_hash["child_dot"] = expect_child_array - expect(@filter.flatten(test_hash)).to eq expect_hash + expect(@filter.filter("tag", "time", test_hash)).to eq expect_hash end it "no error with recursive array with de_dot_nested = true" do @@ -129,7 +140,7 @@ def create_filter expect_hash = {} expect_hash["key"] = "value" expect_hash["child_dot"] = expect_child_array - expect(@filter.flatten(test_hash)).to eq expect_hash + expect(@filter.filter("tag", "time", test_hash)).to eq expect_hash end end