fluentd 0.14.1 → 0.14.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (129) hide show
  1. checksums.yaml +4 -4
  2. data/ChangeLog +110 -1
  3. data/Rakefile +5 -1
  4. data/appveyor.yml +7 -1
  5. data/example/in_forward.conf +4 -0
  6. data/lib/fluent/compat/exec_util.rb +129 -0
  7. data/lib/fluent/compat/file_util.rb +54 -0
  8. data/lib/fluent/compat/filter.rb +21 -3
  9. data/lib/fluent/compat/formatter.rb +4 -2
  10. data/lib/fluent/compat/formatter_utils.rb +85 -0
  11. data/lib/fluent/compat/handle_tag_and_time_mixin.rb +60 -0
  12. data/lib/fluent/compat/input.rb +1 -3
  13. data/lib/fluent/compat/output.rb +95 -39
  14. data/lib/fluent/compat/parser.rb +17 -0
  15. data/lib/fluent/compat/parser_utils.rb +40 -0
  16. data/lib/fluent/compat/socket_util.rb +165 -0
  17. data/lib/fluent/compat/string_util.rb +34 -0
  18. data/lib/fluent/{test/driver/owner.rb → compat/structured_format_mixin.rb} +5 -11
  19. data/lib/fluent/config/element.rb +2 -2
  20. data/lib/fluent/configurable.rb +2 -1
  21. data/lib/fluent/event.rb +61 -7
  22. data/lib/fluent/event_router.rb +1 -1
  23. data/lib/fluent/plugin.rb +7 -7
  24. data/lib/fluent/plugin/buf_file.rb +5 -2
  25. data/lib/fluent/plugin/buffer.rb +194 -64
  26. data/lib/fluent/plugin/buffer/chunk.rb +28 -3
  27. data/lib/fluent/plugin/buffer/file_chunk.rb +5 -21
  28. data/lib/fluent/plugin/buffer/memory_chunk.rb +1 -11
  29. data/lib/fluent/plugin/exec_util.rb +2 -112
  30. data/lib/fluent/plugin/file_util.rb +3 -38
  31. data/lib/fluent/plugin/file_wrapper.rb +1 -1
  32. data/lib/fluent/plugin/filter_grep.rb +3 -7
  33. data/lib/fluent/plugin/filter_record_transformer.rb +5 -5
  34. data/lib/fluent/plugin/filter_stdout.rb +18 -11
  35. data/lib/fluent/plugin/formatter.rb +0 -48
  36. data/lib/fluent/plugin/formatter_csv.rb +7 -8
  37. data/lib/fluent/plugin/formatter_hash.rb +1 -4
  38. data/lib/fluent/plugin/formatter_json.rb +1 -4
  39. data/lib/fluent/plugin/formatter_ltsv.rb +5 -6
  40. data/lib/fluent/plugin/formatter_msgpack.rb +1 -4
  41. data/lib/fluent/plugin/formatter_out_file.rb +36 -3
  42. data/lib/fluent/plugin/formatter_stdout.rb +36 -1
  43. data/lib/fluent/plugin/in_dummy.rb +9 -2
  44. data/lib/fluent/plugin/in_exec.rb +20 -57
  45. data/lib/fluent/plugin/in_forward.rb +4 -3
  46. data/lib/fluent/plugin/in_object_space.rb +8 -44
  47. data/lib/fluent/plugin/in_syslog.rb +13 -24
  48. data/lib/fluent/plugin/in_tail.rb +3 -0
  49. data/lib/fluent/plugin/out_buffered_stdout.rb +14 -4
  50. data/lib/fluent/plugin/out_exec.rb +7 -5
  51. data/lib/fluent/plugin/out_exec_filter.rb +10 -10
  52. data/lib/fluent/plugin/out_file.rb +1 -3
  53. data/lib/fluent/plugin/out_forward.rb +38 -57
  54. data/lib/fluent/plugin/out_stdout.rb +14 -5
  55. data/lib/fluent/plugin/out_stream.rb +3 -0
  56. data/lib/fluent/plugin/output.rb +31 -14
  57. data/lib/fluent/plugin/parser.rb +0 -69
  58. data/lib/fluent/plugin/parser_apache.rb +10 -6
  59. data/lib/fluent/plugin/parser_apache_error.rb +8 -3
  60. data/lib/fluent/plugin/parser_csv.rb +3 -1
  61. data/lib/fluent/plugin/parser_json.rb +1 -1
  62. data/lib/fluent/plugin/parser_multiline.rb +5 -3
  63. data/lib/fluent/plugin/parser_nginx.rb +10 -6
  64. data/lib/fluent/plugin/parser_regexp.rb +73 -0
  65. data/lib/fluent/plugin/socket_util.rb +2 -148
  66. data/lib/fluent/plugin/storage_local.rb +1 -1
  67. data/lib/fluent/plugin/string_util.rb +3 -18
  68. data/lib/fluent/plugin_helper.rb +1 -0
  69. data/lib/fluent/plugin_helper/compat_parameters.rb +166 -41
  70. data/lib/fluent/plugin_helper/formatter.rb +30 -19
  71. data/lib/fluent/plugin_helper/inject.rb +25 -12
  72. data/lib/fluent/plugin_helper/parser.rb +22 -13
  73. data/lib/fluent/plugin_helper/storage.rb +22 -13
  74. data/lib/fluent/registry.rb +19 -6
  75. data/lib/fluent/supervisor.rb +27 -1
  76. data/lib/fluent/test/driver/base.rb +16 -92
  77. data/lib/fluent/test/driver/base_owned.rb +17 -53
  78. data/lib/fluent/test/driver/base_owner.rb +125 -0
  79. data/lib/fluent/test/driver/filter.rb +24 -2
  80. data/lib/fluent/test/driver/input.rb +2 -2
  81. data/lib/fluent/test/driver/multi_output.rb +2 -2
  82. data/lib/fluent/test/driver/output.rb +3 -5
  83. data/lib/fluent/test/helpers.rb +25 -0
  84. data/lib/fluent/test/input_test.rb +4 -4
  85. data/lib/fluent/test/output_test.rb +3 -3
  86. data/lib/fluent/version.rb +1 -1
  87. data/test/config/test_element.rb +135 -6
  88. data/test/plugin/test_buf_file.rb +71 -3
  89. data/test/plugin/test_buffer.rb +305 -86
  90. data/test/plugin/test_buffer_chunk.rb +60 -2
  91. data/test/plugin/test_buffer_file_chunk.rb +4 -3
  92. data/test/plugin/test_filter_grep.rb +25 -21
  93. data/test/plugin/test_filter_record_transformer.rb +75 -67
  94. data/test/plugin/test_filter_stdout.rb +171 -74
  95. data/test/plugin/test_formatter_csv.rb +94 -0
  96. data/test/plugin/test_formatter_json.rb +30 -0
  97. data/test/plugin/test_formatter_ltsv.rb +52 -0
  98. data/test/plugin/test_formatter_msgpack.rb +28 -0
  99. data/test/plugin/test_formatter_out_file.rb +95 -0
  100. data/test/plugin/test_formatter_single_value.rb +38 -0
  101. data/test/plugin/test_in_dummy.rb +95 -0
  102. data/test/plugin/test_in_exec.rb +27 -31
  103. data/test/plugin/test_in_forward.rb +24 -0
  104. data/test/plugin/test_in_gc_stat.rb +5 -5
  105. data/test/plugin/test_in_object_space.rb +4 -4
  106. data/test/plugin/test_in_syslog.rb +60 -35
  107. data/test/plugin/test_out_buffered_stdout.rb +17 -3
  108. data/test/plugin/test_out_forward.rb +93 -5
  109. data/test/plugin/test_out_stdout.rb +14 -3
  110. data/test/plugin/test_output_as_buffered_retries.rb +20 -0
  111. data/test/plugin/test_output_as_buffered_secondary.rb +16 -0
  112. data/test/plugin/test_output_as_standard.rb +22 -22
  113. data/test/plugin/test_parser_apache.rb +13 -9
  114. data/test/plugin/test_parser_apache_error.rb +11 -6
  115. data/test/plugin/test_parser_csv.rb +35 -25
  116. data/test/plugin/test_parser_nginx.rb +11 -5
  117. data/test/plugin/test_parser_regexp.rb +235 -68
  118. data/test/plugin/test_parser_tsv.rb +54 -58
  119. data/test/plugin_helper/test_compat_parameters.rb +111 -46
  120. data/test/plugin_helper/test_formatter.rb +40 -0
  121. data/test/plugin_helper/test_inject.rb +101 -2
  122. data/test/plugin_helper/test_parser.rb +40 -0
  123. data/test/plugin_helper/test_storage.rb +43 -0
  124. data/test/test_event.rb +93 -0
  125. data/test/test_event_router.rb +13 -4
  126. data/test/test_event_time.rb +0 -3
  127. data/test/test_formatter.rb +7 -164
  128. data/test/test_plugin_classes.rb +28 -1
  129. metadata +24 -3
@@ -22,23 +22,22 @@ module Fluent
22
22
  class CsvFormatter < Formatter
23
23
  Plugin.register_formatter('csv', self)
24
24
 
25
- include HandleTagAndTimeMixin
26
-
27
25
  config_param :delimiter, default: ',' do |val|
28
26
  ['\t', 'TAB'].include?(val) ? "\t" : val
29
27
  end
30
28
  config_param :force_quotes, :bool, default: true
31
29
  # "array" looks good for type of :fields, but this implementation removes tailing comma
32
30
  # TODO: Is it needed to support tailing comma?
33
- config_param :fields, default: [] do |val|
34
- val.split(',').map{|f| f.strip!; f.empty? ? nil : f }.compact
31
+ config_param :fields, :array, value_type: :string
32
+
33
+ def configure(conf)
34
+ super
35
+ @fields = fields.select{|f| !f.empty? }
35
36
  end
36
37
 
37
38
  def format(tag, time, record)
38
- filter_record(tag, time, record)
39
- row = @fields.inject([]) do |memo, key|
40
- memo << record[key]
41
- memo
39
+ row = @fields.map do |key|
40
+ record[key]
42
41
  end
43
42
  CSV.generate_line(row, col_sep: @delimiter,
44
43
  force_quotes: @force_quotes)
@@ -21,10 +21,7 @@ module Fluent
21
21
  class HashFormatter < Formatter
22
22
  Plugin.register_formatter('hash', self)
23
23
 
24
- include HandleTagAndTimeMixin
25
- include StructuredFormatMixin
26
-
27
- def format_record(record)
24
+ def format(tag, time, record)
28
25
  "#{record.to_s}\n"
29
26
  end
30
27
  end
@@ -21,9 +21,6 @@ module Fluent
21
21
  class JSONFormatter < Formatter
22
22
  Plugin.register_formatter('json', self)
23
23
 
24
- include HandleTagAndTimeMixin
25
- include StructuredFormatMixin
26
-
27
24
  config_param :json_parser, :string, default: 'oj'
28
25
 
29
26
  def configure(conf)
@@ -39,7 +36,7 @@ module Fluent
39
36
  end
40
37
  end
41
38
 
42
- def format_record(record)
39
+ def format(tag, time, record)
43
40
  "#{@dump_proc.call(record)}\n"
44
41
  end
45
42
  end
@@ -22,18 +22,17 @@ module Fluent
22
22
  Plugin.register_formatter('ltsv', self)
23
23
 
24
24
  # http://ltsv.org/
25
- include HandleTagAndTimeMixin
26
25
 
27
26
  config_param :delimiter, :string, default: "\t"
28
27
  config_param :label_delimiter, :string, default: ":"
29
28
 
30
29
  # TODO: escaping for \t in values
31
30
  def format(tag, time, record)
32
- filter_record(tag, time, record)
33
- formatted = record.inject('') { |result, pair|
34
- result << @delimiter if result.length.nonzero?
35
- result << "#{pair.first}#{@label_delimiter}#{pair.last}"
36
- }
31
+ formatted = ""
32
+ record.each do |label, value|
33
+ formatted << @delimiter if formatted.length.nonzero?
34
+ formatted << "#{label}#{@label_delimiter}#{value}"
35
+ end
37
36
  formatted << "\n"
38
37
  formatted
39
38
  end
@@ -21,10 +21,7 @@ module Fluent
21
21
  class MessagePackFormatter < Formatter
22
22
  Plugin.register_formatter('msgpack', self)
23
23
 
24
- include HandleTagAndTimeMixin
25
- include StructuredFormatMixin
26
-
27
- def format_record(record)
24
+ def format(tag, time, record)
28
25
  record.to_msgpack
29
26
  end
30
27
  end
@@ -15,14 +15,14 @@
15
15
  #
16
16
 
17
17
  require 'fluent/plugin/formatter'
18
+ require 'fluent/time'
19
+ require 'yajl'
18
20
 
19
21
  module Fluent
20
22
  module Plugin
21
23
  class OutFileFormatter < Formatter
22
24
  Plugin.register_formatter('out_file', self)
23
25
 
24
- include HandleTagAndTimeMixin
25
-
26
26
  config_param :output_time, :bool, default: true
27
27
  config_param :output_tag, :bool, default: true
28
28
  config_param :delimiter, default: "\t" do |val|
@@ -32,9 +32,42 @@ module Fluent
32
32
  else "\t"
33
33
  end
34
34
  end
35
+ config_param :time_type, :enum, list: [:float, :unixtime, :string], default: :string
36
+ config_param :time_format, :string, default: nil
37
+ config_param :localtime, :bool, default: true # if localtime is false and timezone is nil, then utc
38
+ config_param :timezone, :string, default: nil
39
+
40
+ def configure(conf)
41
+ # TODO: make a utility method in TimeFormatter to handle these conversion
42
+ # copies of this code: plugin_helper/compat_parameters, compat/formatter_utils and here
43
+ if conf.has_key?('time_as_epoch') && Fluent::Config.bool_value(conf['time_as_epoch'])
44
+ conf['time_type'] = 'unixtime'
45
+ end
46
+ if conf.has_key?('localtime') || conf.has_key?('utc')
47
+ if conf.has_key?('localtime') && conf.has_key?('utc')
48
+ raise Fluent::ConfigError, "both of utc and localtime are specified, use only one of them"
49
+ elsif conf.has_key?('localtime')
50
+ conf['localtime'] = Fluent::Config.bool_value(conf['localtime'])
51
+ elsif conf.has_key?('utc')
52
+ conf['localtime'] = !(Fluent::Config.bool_value(conf['utc']))
53
+ # Specifying "localtime false" means using UTC in TimeFormatter
54
+ # And specifying "utc" is different from specifying "timezone +0000"(it's not always UTC).
55
+ # There are difference between "Z" and "+0000" in timezone formatting.
56
+ # TODO: add kwargs to TimeFormatter to specify "using localtime", "using UTC" or "using specified timezone" in more explicit way
57
+ end
58
+ end
59
+
60
+ super
61
+
62
+ @timef = case @time_type
63
+ when :float then ->(time){ time.to_r.to_f }
64
+ when :unixtime then ->(time){ time.to_i }
65
+ else
66
+ Fluent::TimeFormatter.new(@time_format, @localtime, @timezone)
67
+ end
68
+ end
35
69
 
36
70
  def format(tag, time, record)
37
- filter_record(tag, time, record)
38
71
  header = ''
39
72
  header << "#{@timef.format(time)}#{@delimiter}" if @output_time
40
73
  header << "#{tag}#{@delimiter}" if @output_tag
@@ -26,14 +26,49 @@ module Fluent
26
26
  def configure(conf)
27
27
  super
28
28
 
29
- @sub_formatter = Plugin.new_formatter(@output_type)
29
+ @sub_formatter = Plugin.new_formatter(@output_type, parent: self.owner)
30
30
  @sub_formatter.configure(conf)
31
31
  end
32
32
 
33
+ def start
34
+ super
35
+ @sub_formatter.start
36
+ end
37
+
33
38
  def format(tag, time, record)
34
39
  header = "#{Time.now.localtime} #{tag}: "
35
40
  "#{header}#{@sub_formatter.format(tag, time, record)}"
36
41
  end
42
+
43
+ def stop
44
+ @sub_formatter.stop
45
+ super
46
+ end
47
+
48
+ def before_shutdown
49
+ @sub_formatter.before_shutdown
50
+ super
51
+ end
52
+
53
+ def shutdown
54
+ @sub_formatter.shutdown
55
+ super
56
+ end
57
+
58
+ def after_shutdown
59
+ @sub_formatter.after_shutdown
60
+ super
61
+ end
62
+
63
+ def close
64
+ @sub_formatter.close
65
+ super
66
+ end
67
+
68
+ def terminate
69
+ @sub_formatter.terminate
70
+ super
71
+ end
37
72
  end
38
73
  end
39
74
  end
@@ -26,6 +26,7 @@ module Fluent::Plugin
26
26
  helpers :thread, :storage
27
27
 
28
28
  BIN_NUM = 10
29
+ DEFAULT_STORAGE_TYPE = 'local'
29
30
 
30
31
  desc "The value is the tag assigned to the generated events."
31
32
  config_param :tag, :string
@@ -33,6 +34,8 @@ module Fluent::Plugin
33
34
  config_param :rate, :integer, default: 1
34
35
  desc "If specified, each generated event has an auto-incremented key field."
35
36
  config_param :auto_increment_key, :string, default: nil
37
+ desc "The boolean to suspend-and-resume incremental value after restart"
38
+ config_param :suspend, :bool, default: false
36
39
  desc "The dummy data to be generated. An array of JSON hashes or a single JSON hash."
37
40
  config_param :dummy, default: [{"message"=>"dummy"}] do |val|
38
41
  begin
@@ -58,12 +61,16 @@ module Fluent::Plugin
58
61
  def configure(conf)
59
62
  super
60
63
  @dummy_index = 0
64
+ config = conf.elements.select{|e| e.name == 'storage' }.first
65
+ @storage = storage_create(usage: 'suspend', conf: config, default_type: DEFAULT_STORAGE_TYPE)
61
66
  end
62
67
 
63
68
  def start
64
69
  super
65
70
 
66
- @storage = storage_create(type: 'local')
71
+ @storage.put(:increment_value, 0) unless @storage.get(:increment_value)
72
+ @storage.put(:dummy_index, 0) unless @storage.get(:dummy_index)
73
+
67
74
  if @auto_increment_key && !@storage.get(:auto_increment_value)
68
75
  @storage.put(:auto_increment_value, -1)
69
76
  end
@@ -100,7 +107,7 @@ module Fluent::Plugin
100
107
  d = @dummy[@dummy_index]
101
108
  unless d
102
109
  @dummy_index = 0
103
- d = @dummy[0]
110
+ d = @dummy[@dummy_index]
104
111
  end
105
112
  @dummy_index += 1
106
113
  if @auto_increment_key
@@ -17,14 +17,16 @@
17
17
  require 'strptime'
18
18
  require 'yajl'
19
19
 
20
- require 'fluent/input'
20
+ require 'fluent/plugin/input'
21
21
  require 'fluent/time'
22
22
  require 'fluent/timezone'
23
23
  require 'fluent/config/error'
24
24
 
25
- module Fluent
26
- class ExecInput < Input
27
- Plugin.register_input('exec', self)
25
+ module Fluent::Plugin
26
+ class ExecInput < Fluent::Plugin::Input
27
+ Fluent::Plugin.register_input('exec', self)
28
+
29
+ helpers :child_process
28
30
 
29
31
  def initialize
30
32
  super
@@ -65,7 +67,7 @@ module Fluent
65
67
  end
66
68
 
67
69
  if !@tag && !@tag_key
68
- raise ConfigError, "'tag' or 'tag_key' option is required on exec input"
70
+ raise Fleunt::ConfigError, "'tag' or 'tag_key' option is required on exec input"
69
71
  end
70
72
 
71
73
  if @time_key
@@ -90,15 +92,15 @@ module Fluent
90
92
  case @format
91
93
  when 'tsv'
92
94
  if @keys.empty?
93
- raise ConfigError, "keys option is required on exec input for tsv format"
95
+ raise Fluent::ConfigError, "keys option is required on exec input for tsv format"
94
96
  end
95
- ExecUtil::TSVParser.new(@keys, method(:on_message))
97
+ Fluent::ExecUtil::TSVParser.new(@keys, method(:on_message))
96
98
  when 'json'
97
- ExecUtil::JSONParser.new(method(:on_message))
99
+ Fluent::ExecUtil::JSONParser.new(method(:on_message))
98
100
  when 'msgpack'
99
- ExecUtil::MessagePackParser.new(method(:on_message))
101
+ Fluent::ExecUtil::MessagePackParser.new(method(:on_message))
100
102
  else
101
- ExecUtil::TextParserWrapperParser.new(conf, method(:on_message))
103
+ Fluent::ExecUtil::TextParserWrapperParser.new(conf, method(:on_message))
102
104
  end
103
105
  end
104
106
 
@@ -106,57 +108,18 @@ module Fluent
106
108
  super
107
109
 
108
110
  if @run_interval
109
- @finished = false
110
- @thread = Thread.new(&method(:run_periodic))
111
- else
112
- @io = IO.popen(@command, "r")
113
- @pid = @io.pid
114
- @thread = Thread.new(&method(:run))
115
- end
116
- end
117
-
118
- def shutdown
119
- if @run_interval
120
- @finished = true
121
- # call Thread#run which interupts sleep in order to stop run_periodic thread immediately.
122
- @thread.run
123
- @thread.join
124
- else
125
- begin
126
- Process.kill(:TERM, @pid)
127
- rescue #Errno::ECHILD, Errno::ESRCH, Errno::EPERM
128
- end
129
- if @thread.join(60) # TODO wait time
130
- return
111
+ child_process_execute(:exec_input, @command, interval: @run_interval, mode: [:read]) do |io|
112
+ run(io)
131
113
  end
132
-
133
- begin
134
- Process.kill(:KILL, @pid)
135
- rescue #Errno::ECHILD, Errno::ESRCH, Errno::EPERM
114
+ else
115
+ child_process_execute(:exec_input, @command, immediate: true, mode: [:read]) do |io|
116
+ run(io)
136
117
  end
137
- @thread.join
138
118
  end
139
-
140
- super
141
119
  end
142
120
 
143
- def run
144
- @parser.call(@io)
145
- end
146
-
147
- def run_periodic
148
- sleep @run_interval
149
- until @finished
150
- begin
151
- io = IO.popen(@command, "r")
152
- @parser.call(io)
153
- Process.waitpid(io.pid)
154
- sleep @run_interval
155
- rescue
156
- log.error "exec failed to run or shutdown child process", error: $!
157
- log.warn_backtrace $!.backtrace
158
- end
159
- end
121
+ def run(io)
122
+ @parser.call(io)
160
123
  end
161
124
 
162
125
  private
@@ -174,7 +137,7 @@ module Fluent
174
137
  if val = record.delete(@time_key)
175
138
  time = @time_parse_proc.call(val)
176
139
  else
177
- time = Engine.now
140
+ time = Fluent::EventTime.now
178
141
  end
179
142
  end
180
143
 
@@ -169,10 +169,11 @@ module Fluent
169
169
 
170
170
  if entries.class == String
171
171
  # PackedForward
172
- es = MessagePackEventStream.new(entries)
172
+ option = msg[2]
173
+ size = (option && option['size']) || 0
174
+ es = MessagePackEventStream.new(entries, nil, size.to_i)
173
175
  es = check_and_skip_invalid_event(tag, es, source) if @skip_invalid_event
174
176
  router.emit_stream(tag, es)
175
- option = msg[2]
176
177
 
177
178
  elsif entries.class == Array
178
179
  # Forward
@@ -265,7 +266,7 @@ module Fluent
265
266
  @y = Yajl::Parser.new
266
267
  @y.on_parse_complete = lambda { |obj|
267
268
  option = @on_message.call(obj, @chunk_counter, @source)
268
- respond option if option
269
+ respond option
269
270
  @chunk_counter = 0
270
271
  }
271
272
  else
@@ -17,11 +17,13 @@
17
17
  require 'cool.io'
18
18
  require 'yajl'
19
19
 
20
- require 'fluent/input'
20
+ require 'fluent/plugin/input'
21
21
 
22
- module Fluent
23
- class ObjectSpaceInput < Input
24
- Plugin.register_input('object_space', self)
22
+ module Fluent::Plugin
23
+ class ObjectSpaceInput < Fluent::Plugin::Input
24
+ Fluent::Plugin.register_input('object_space', self)
25
+
26
+ helpers :timer
25
27
 
26
28
  def initialize
27
29
  super
@@ -31,48 +33,10 @@ module Fluent
31
33
  config_param :tag, :string
32
34
  config_param :top, :integer, default: 15
33
35
 
34
- class TimerWatcher < Coolio::TimerWatcher
35
- def initialize(interval, repeat, log, &callback)
36
- @callback = callback
37
- @log = log
38
- super(interval, repeat)
39
- end
40
-
41
- def on_timer
42
- @callback.call
43
- rescue
44
- # TODO log?
45
- @log.error $!.to_s
46
- @log.error_backtrace
47
- end
48
- end
49
-
50
- def configure(conf)
51
- super
52
- end
53
-
54
36
  def start
55
37
  super
56
38
 
57
- @loop = Coolio::Loop.new
58
- @timer = TimerWatcher.new(@emit_interval, true, log, &method(:on_timer))
59
- @loop.attach(@timer)
60
- @thread = Thread.new(&method(:run))
61
- end
62
-
63
- def shutdown
64
- @loop.watchers.each {|w| w.detach }
65
- @loop.stop
66
- @thread.join
67
-
68
- super
69
- end
70
-
71
- def run
72
- @loop.run
73
- rescue
74
- log.error "unexpected error", error: $!.to_s
75
- log.error_backtrace
39
+ timer_execute(:object_space_input, @emit_interval, &method(:on_timer))
76
40
  end
77
41
 
78
42
  class Counter
@@ -93,7 +57,7 @@ module Fluent
93
57
  end
94
58
 
95
59
  def on_timer
96
- now = Engine.now
60
+ now = Fluent::EventTime.now
97
61
 
98
62
  array = []
99
63
  map = {}