Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion fluent-plugin-better-timestamp.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ Gem::Specification.new do |gem|
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
gem.require_paths = ['lib']

gem.add_dependency "fluentd", "~> 0.10.17"
gem.add_dependency "fluentd", [">= 0.10.17", "< 2"]
gem.add_dependency "fluent-mixin-config-placeholders", ">= 0.3.0"
gem.add_development_dependency "rake", ">= 0.9.2"
gem.add_development_dependency "test-unit", ">= 3.2.0"
end
8 changes: 6 additions & 2 deletions lib/fluent/plugin/out_better_timestamp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ module Fluent
class BetterTimestampOutput < Output
Fluent::Plugin.register_output('better_timestamp', self)

# Define `router` method of v0.12 to support v0.10 or earlier
unless method_defined?(:router)
define_method("router") { Fluent::Engine }
end

config_param :tag, :string
config_param :msec_key, :string, :default => 'msec'
config_param :timestamp_key, :string, :default => '@timestamp'
Expand All @@ -23,13 +28,12 @@ def configure(conf)
@map[k] = v
end
}

end

def emit(tag, es, chain)
es.each { |time, record|
filter_record(tag, time, record)
Engine.emit(@tag, time, modify_record(time, record))
router.emit(@tag, time, modify_record(time, record))
}

chain.next
Expand Down
8 changes: 4 additions & 4 deletions test/out_better_timestamp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def setup
type better_timestamp
tag foo.filtered
msec_key msec
timestamp_key
timestamp_key @timestamp
]

def create_driver(conf = CONFIG)
Expand All @@ -19,9 +19,8 @@ def create_driver(conf = CONFIG)

def test_configure
d = create_driver
map = d.instance.instance_variable_get(:@map)

#assert_equal 'msec', map['msec_key']
assert_equal 'msec', d.instance.msec_key
end

def test_remove_one_key
Expand All @@ -33,8 +32,9 @@ def test_remove_one_key

mapped = {}

msec = 1
d.run do
d.emit("msec" => '1', "k1" => 'v')
d.emit({"msec" => msec, "k1" => 'v'})
end

assert d.records[0]['@timestamp']
Expand Down