Permalink
Browse files

Fix degraded bug not to emit message when only values changed not tag.

  • Loading branch information...
1 parent d348b29 commit 70213dd49d8e46b784cae7d66f7e29f921bef422 @kentaro committed Jul 4, 2012
Showing with 27 additions and 11 deletions.
  1. +1 −1 fluent-plugin-rewrite.gemspec
  2. +2 −2 lib/fluent/plugin/out_rewrite.rb
  3. +24 −8 test/plugin/test_out_rewrite.rb
@@ -1,6 +1,6 @@
Gem::Specification.new do |gem|
gem.name = "fluent-plugin-rewrite"
- gem.version = '0.0.6'
+ gem.version = '0.0.7'
gem.authors = ["Kentaro Kuribayashi"]
gem.email = ["kentarok@gmail.com"]
gem.homepage = "http://github.com/kentaro/fluent-plugin-rewrite"
@@ -51,8 +51,8 @@ def emit(tag, es, chain)
end
es.each do |time, record|
- filtered_tag, record = rewrite(tag, record)
- Engine.emit(filtered_tag, time, record) if (filtered_tag && record) && (filtered_tag != tag)
+ tag, record = rewrite(tag, record)
+ Engine.emit(tag, time, record) if tag && record
end
chain.next
@@ -247,7 +247,7 @@ def test_rewrite_rules
end
def test_emit
- d = create_driver(%[
+ d1 = create_driver(%[
remove_prefix test
add_prefix filtered
@@ -269,14 +269,14 @@ def test_emit
</rule>
])
- d.run do
- d.emit({ "path" => "/foo?bar=1" })
- d.emit({ "path" => "/foo?bar=1", "status" => "500" })
- d.emit({ "path" => "/users/antipop" })
- d.emit({ "path" => "/users/kentaro" })
- d.emit({ "path" => "/entries/1" })
+ d1.run do
+ d1.emit({ "path" => "/foo?bar=1" })
+ d1.emit({ "path" => "/foo?bar=1", "status" => "500" })
+ d1.emit({ "path" => "/users/antipop" })
+ d1.emit({ "path" => "/users/kentaro" })
+ d1.emit({ "path" => "/entries/1" })
end
- emits = d.emits
+ emits = d1.emits
assert_equal 4, emits.size
assert_equal('filtered.others', emits[0][0])
@@ -287,5 +287,21 @@ def test_emit
assert_equal({ "path" => "/users/kentaro" }, emits[2][2])
assert_equal('filtered.entries', emits[3][0])
assert_equal({ "path" => "/entries/1" }, emits[3][2])
+
+ d2 = create_driver(%[
+ <rule>
+ key path
+ pattern \\?.+$
+ replace
+ </rule>
+ ])
+ d2.run do
+ d2.emit({ "path" => "/foo?bar=1" })
+ end
+ emits = d2.emits
+
+ assert_equal 1, emits.size
+ assert_equal('test', emits[0][0])
+ assert_equal({ "path" => "/foo" }, emits[0][2])
end
end

0 comments on commit 70213dd

Please sign in to comment.