fluentd 0.12.20 → 0.12.21
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of fluentd might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/ChangeLog +23 -0
- data/Rakefile +2 -2
- data/bin/fluent-debug +0 -1
- data/lib/fluent/agent.rb +12 -9
- data/lib/fluent/buffer.rb +9 -3
- data/lib/fluent/command/bundler_injection.rb +2 -0
- data/lib/fluent/command/cat.rb +1 -1
- data/lib/fluent/command/debug.rb +3 -2
- data/lib/fluent/command/fluentd.rb +3 -1
- data/lib/fluent/config.rb +4 -5
- data/lib/fluent/config/basic_parser.rb +3 -4
- data/lib/fluent/config/configure_proxy.rb +2 -0
- data/lib/fluent/config/dsl.rb +3 -0
- data/lib/fluent/config/element.rb +3 -2
- data/lib/fluent/config/literal_parser.rb +8 -5
- data/lib/fluent/config/parser.rb +5 -3
- data/lib/fluent/config/section.rb +3 -3
- data/lib/fluent/config/types.rb +44 -50
- data/lib/fluent/config/v1_parser.rb +8 -6
- data/lib/fluent/configurable.rb +8 -6
- data/lib/fluent/engine.rb +23 -11
- data/lib/fluent/event.rb +2 -0
- data/lib/fluent/event_router.rb +4 -2
- data/lib/fluent/filter.rb +6 -0
- data/lib/fluent/formatter.rb +27 -25
- data/lib/fluent/input.rb +5 -0
- data/lib/fluent/label.rb +2 -2
- data/lib/fluent/log.rb +5 -2
- data/lib/fluent/mixin.rb +4 -2
- data/lib/fluent/output.rb +45 -31
- data/lib/fluent/parser.rb +35 -25
- data/lib/fluent/plugin.rb +4 -0
- data/lib/fluent/plugin/buf_file.rb +9 -2
- data/lib/fluent/plugin/buf_memory.rb +7 -1
- data/lib/fluent/plugin/exec_util.rb +7 -2
- data/lib/fluent/plugin/filter_grep.rb +6 -3
- data/lib/fluent/plugin/filter_record_transformer.rb +52 -51
- data/lib/fluent/plugin/filter_stdout.rb +4 -1
- data/lib/fluent/plugin/in_debug_agent.rb +7 -5
- data/lib/fluent/plugin/in_dummy.rb +8 -3
- data/lib/fluent/plugin/in_exec.rb +16 -10
- data/lib/fluent/plugin/in_forward.rb +18 -11
- data/lib/fluent/plugin/in_gc_stat.rb +6 -2
- data/lib/fluent/plugin/in_http.rb +23 -14
- data/lib/fluent/plugin/in_monitor_agent.rb +24 -17
- data/lib/fluent/plugin/in_object_space.rb +9 -4
- data/lib/fluent/plugin/in_stream.rb +15 -6
- data/lib/fluent/plugin/in_syslog.rb +18 -12
- data/lib/fluent/plugin/in_tail.rb +61 -40
- data/lib/fluent/plugin/in_tcp.rb +3 -1
- data/lib/fluent/plugin/in_udp.rb +1 -1
- data/lib/fluent/plugin/out_copy.rb +5 -1
- data/lib/fluent/plugin/out_exec.rb +9 -6
- data/lib/fluent/plugin/out_exec_filter.rb +32 -25
- data/lib/fluent/plugin/out_file.rb +11 -5
- data/lib/fluent/plugin/out_forward.rb +30 -24
- data/lib/fluent/plugin/out_null.rb +2 -0
- data/lib/fluent/plugin/out_relabel.rb +2 -0
- data/lib/fluent/plugin/out_roundrobin.rb +3 -0
- data/lib/fluent/plugin/out_stdout.rb +3 -1
- data/lib/fluent/plugin/out_stream.rb +8 -8
- data/lib/fluent/plugin/socket_util.rb +12 -10
- data/lib/fluent/process.rb +14 -8
- data/lib/fluent/registry.rb +2 -2
- data/lib/fluent/root_agent.rb +16 -12
- data/lib/fluent/rpc.rb +7 -7
- data/lib/fluent/supervisor.rb +35 -69
- data/lib/fluent/system_config.rb +98 -0
- data/lib/fluent/test.rb +1 -1
- data/lib/fluent/test/base.rb +6 -1
- data/lib/fluent/test/filter_test.rb +4 -0
- data/lib/fluent/test/formatter_test.rb +3 -2
- data/lib/fluent/test/input_test.rb +6 -0
- data/lib/fluent/test/output_test.rb +4 -0
- data/lib/fluent/test/parser_test.rb +3 -2
- data/lib/fluent/timezone.rb +2 -0
- data/lib/fluent/version.rb +1 -1
- data/test/config/test_configurable.rb +11 -11
- data/test/config/test_configure_proxy.rb +1 -1
- data/test/config/test_system_config.rb +5 -5
- data/test/config/test_types.rb +70 -0
- data/test/plugin/test_filter_record_transformer.rb +72 -55
- data/test/plugin/test_in_forward.rb +4 -0
- data/test/plugin/test_in_tail.rb +73 -2
- data/test/test_config.rb +2 -2
- data/test/test_event_router.rb +1 -0
- data/test/test_output.rb +27 -3
- data/test/test_plugin_classes.rb +3 -0
- data/test/test_process.rb +1 -0
- data/test/test_root_agent.rb +5 -3
- metadata +3 -2
data/lib/fluent/process.rb
CHANGED
@@ -14,6 +14,12 @@
|
|
14
14
|
# limitations under the License.
|
15
15
|
#
|
16
16
|
|
17
|
+
require 'thread'
|
18
|
+
|
19
|
+
require 'fluent/config'
|
20
|
+
require 'fluent/engine'
|
21
|
+
require 'fluent/event'
|
22
|
+
|
17
23
|
module Fluent
|
18
24
|
class DetachProcessManager
|
19
25
|
require 'singleton'
|
@@ -149,12 +155,12 @@ module Fluent
|
|
149
155
|
begin
|
150
156
|
target.emit(tag, es, NullOutputChain.instance)
|
151
157
|
rescue
|
152
|
-
$log.warn "failed to emit", :
|
158
|
+
$log.warn "failed to emit", error: $!.to_s, pid: Process.pid
|
153
159
|
$log.warn_backtrace
|
154
160
|
end
|
155
161
|
}
|
156
162
|
rescue
|
157
|
-
$log.error "error on output process forwarding thread", :
|
163
|
+
$log.error "error on output process forwarding thread", error: $!.to_s, pid: Process.pid
|
158
164
|
$log.error_backtrace
|
159
165
|
raise
|
160
166
|
end
|
@@ -165,12 +171,12 @@ module Fluent
|
|
165
171
|
begin
|
166
172
|
Engine.emit_stream(tag, es)
|
167
173
|
rescue
|
168
|
-
$log.warn "failed to emit", :
|
174
|
+
$log.warn "failed to emit", error: $!.to_s, pid: Process.pid
|
169
175
|
$log.warn_backtrace
|
170
176
|
end
|
171
177
|
}
|
172
178
|
rescue
|
173
|
-
$log.error "error on input process forwarding thread", :
|
179
|
+
$log.error "error on input process forwarding thread", error: $!.to_s, pid: Process.pid
|
174
180
|
$log.error_backtrace
|
175
181
|
raise
|
176
182
|
end
|
@@ -264,7 +270,7 @@ module Fluent
|
|
264
270
|
end
|
265
271
|
end
|
266
272
|
rescue
|
267
|
-
$log.error "error on forwerder thread", :
|
273
|
+
$log.error "error on forwerder thread", error: $!.to_s
|
268
274
|
$log.error_backtrace
|
269
275
|
raise
|
270
276
|
end
|
@@ -302,7 +308,7 @@ module Fluent
|
|
302
308
|
|
303
309
|
if pid
|
304
310
|
# parent process
|
305
|
-
$log.info "detached process", :
|
311
|
+
$log.info "detached process", class: self.class, pid: pid
|
306
312
|
children << [pid, forward_thread]
|
307
313
|
next
|
308
314
|
end
|
@@ -332,7 +338,7 @@ module Fluent
|
|
332
338
|
on_exit_process(i)
|
333
339
|
exit! 0
|
334
340
|
ensure
|
335
|
-
$log.error "unknown error while shutting down this child process", :
|
341
|
+
$log.error "unknown error while shutting down this child process", error: $!.to_s, pid: Process.pid
|
336
342
|
$log.error_backtrace
|
337
343
|
end
|
338
344
|
|
@@ -353,7 +359,7 @@ module Fluent
|
|
353
359
|
pair[0] = nil
|
354
360
|
end
|
355
361
|
rescue
|
356
|
-
$log.error "unknown error while shutting down remote child process", :
|
362
|
+
$log.error "unknown error while shutting down remote child process", error: $!.to_s
|
357
363
|
$log.error_backtrace
|
358
364
|
end
|
359
365
|
}
|
data/lib/fluent/registry.rb
CHANGED
data/lib/fluent/root_agent.rb
CHANGED
@@ -13,13 +13,17 @@
|
|
13
13
|
# See the License for the specific language governing permissions and
|
14
14
|
# limitations under the License.
|
15
15
|
#
|
16
|
-
module Fluent
|
17
16
|
|
18
|
-
|
17
|
+
require 'delegate'
|
19
18
|
|
20
|
-
|
21
|
-
|
19
|
+
require 'fluent/config/error'
|
20
|
+
require 'fluent/agent'
|
21
|
+
require 'fluent/engine'
|
22
|
+
require 'fluent/label'
|
23
|
+
require 'fluent/plugin'
|
24
|
+
require 'fluent/system_config'
|
22
25
|
|
26
|
+
module Fluent
|
23
27
|
#
|
24
28
|
# Fluentd forms a tree structure to manage plugins:
|
25
29
|
#
|
@@ -43,7 +47,7 @@ module Fluent
|
|
43
47
|
class RootAgent < Agent
|
44
48
|
ERROR_LABEL = "@ERROR".freeze # @ERROR is built-in error label
|
45
49
|
|
46
|
-
def initialize(
|
50
|
+
def initialize(system_config = SystemConfig.new)
|
47
51
|
super
|
48
52
|
|
49
53
|
@labels = {}
|
@@ -52,8 +56,8 @@ module Fluent
|
|
52
56
|
@suppress_emit_error_log_interval = 0
|
53
57
|
@next_emit_error_log_time = nil
|
54
58
|
|
55
|
-
suppress_interval(
|
56
|
-
@without_source =
|
59
|
+
suppress_interval(system_config.emit_error_log_interval) unless system_config.emit_error_log_interval.nil?
|
60
|
+
@without_source = system_config.without_source unless system_config.without_source.nil?
|
57
61
|
end
|
58
62
|
|
59
63
|
attr_reader :inputs
|
@@ -121,7 +125,7 @@ module Fluent
|
|
121
125
|
log.info "shutting down input", type: Plugin.lookup_name_from_class(i.class), plugin_id: i.plugin_id
|
122
126
|
i.shutdown
|
123
127
|
rescue => e
|
124
|
-
log.warn "unexpected error while shutting down input plugin", :
|
128
|
+
log.warn "unexpected error while shutting down input plugin", plugin: i.class, plugin_id: i.plugin_id, error_class: e.class, error: e
|
125
129
|
log.warn_backtrace
|
126
130
|
end
|
127
131
|
end
|
@@ -168,7 +172,7 @@ module Fluent
|
|
168
172
|
end
|
169
173
|
|
170
174
|
def emit_error_event(tag, time, record, error)
|
171
|
-
error_info = {:
|
175
|
+
error_info = {error_class: error.class, error: error.to_s, tag: tag, time: time}
|
172
176
|
if @error_collector
|
173
177
|
# A record is not included in the logs because <@ERROR> handles it. This warn is for the notification
|
174
178
|
log.warn "send an error event to @ERROR:", error_info
|
@@ -180,7 +184,7 @@ module Fluent
|
|
180
184
|
end
|
181
185
|
|
182
186
|
def handle_emits_error(tag, es, error)
|
183
|
-
error_info = {:
|
187
|
+
error_info = {error_class: error.class, error: error.to_s, tag: tag}
|
184
188
|
if @error_collector
|
185
189
|
log.warn "send an error event stream to @ERROR:", error_info
|
186
190
|
@error_collector.emit_stream(tag, es)
|
@@ -209,14 +213,14 @@ module Fluent
|
|
209
213
|
end
|
210
214
|
|
211
215
|
def emit_error_event(tag, time, record, error)
|
212
|
-
error_info = {:
|
216
|
+
error_info = {error_class: error.class, error: error.to_s, tag: tag, time: time, record: record}
|
213
217
|
log.warn "dump an error event in @ERROR:", error_info
|
214
218
|
end
|
215
219
|
|
216
220
|
def handle_emits_error(tag, es, e)
|
217
221
|
now = Engine.now
|
218
222
|
if @suppress_emit_error_log_interval.zero? || now > @next_emit_error_log_time
|
219
|
-
log.warn "emit transaction failed in @ERROR:", :
|
223
|
+
log.warn "emit transaction failed in @ERROR:", error_class: e.class, error: e, tag: tag
|
220
224
|
log.warn_backtrace
|
221
225
|
@next_emit_error_log_time = now + @suppress_emit_error_log_interval
|
222
226
|
end
|
data/lib/fluent/rpc.rb
CHANGED
@@ -14,10 +14,10 @@
|
|
14
14
|
# limitations under the License.
|
15
15
|
#
|
16
16
|
|
17
|
+
require 'webrick'
|
18
|
+
|
17
19
|
module Fluent
|
18
20
|
module RPC
|
19
|
-
require 'webrick'
|
20
|
-
|
21
21
|
class Server
|
22
22
|
def initialize(endpoint, log)
|
23
23
|
bind, port = endpoint.split(':')
|
@@ -26,10 +26,10 @@ module Fluent
|
|
26
26
|
@log = log
|
27
27
|
|
28
28
|
@server = WEBrick::HTTPServer.new(
|
29
|
-
:
|
30
|
-
:
|
31
|
-
:
|
32
|
-
:
|
29
|
+
BindAddress: @bind,
|
30
|
+
Port: @port,
|
31
|
+
Logger: WEBrick::Log.new(STDERR, WEBrick::Log::FATAL),
|
32
|
+
AccessLog: [],
|
33
33
|
)
|
34
34
|
end
|
35
35
|
|
@@ -43,7 +43,7 @@ module Fluent
|
|
43
43
|
begin
|
44
44
|
code, header, response = block.call(req, res)
|
45
45
|
rescue => e
|
46
|
-
@log.warn "failed to handle RPC request", :
|
46
|
+
@log.warn "failed to handle RPC request", path: path, error: e.to_s
|
47
47
|
@log.warn_backtrace e.backtrace
|
48
48
|
|
49
49
|
code = 500
|
data/lib/fluent/supervisor.rb
CHANGED
@@ -14,9 +14,16 @@
|
|
14
14
|
# limitations under the License.
|
15
15
|
#
|
16
16
|
|
17
|
-
require 'fluent/load'
|
18
17
|
require 'etc'
|
19
18
|
|
19
|
+
require 'fluent/config'
|
20
|
+
require 'fluent/env'
|
21
|
+
require 'fluent/engine'
|
22
|
+
require 'fluent/log'
|
23
|
+
require 'fluent/plugin'
|
24
|
+
require 'fluent/rpc'
|
25
|
+
require 'fluent/system_config'
|
26
|
+
|
20
27
|
module Fluent
|
21
28
|
class Supervisor
|
22
29
|
def self.get_etc_passwd(user)
|
@@ -80,20 +87,20 @@ module Fluent
|
|
80
87
|
|
81
88
|
def self.default_options
|
82
89
|
{
|
83
|
-
:
|
84
|
-
:
|
85
|
-
:
|
86
|
-
:
|
87
|
-
:
|
88
|
-
:
|
89
|
-
:
|
90
|
-
:
|
91
|
-
:
|
92
|
-
:
|
93
|
-
:
|
94
|
-
:
|
95
|
-
:
|
96
|
-
:
|
90
|
+
config_path: Fluent::DEFAULT_CONFIG_PATH,
|
91
|
+
plugin_dirs: [Fluent::DEFAULT_PLUGIN_DIR],
|
92
|
+
log_level: Fluent::Log::LEVEL_INFO,
|
93
|
+
log_path: nil,
|
94
|
+
daemonize: nil,
|
95
|
+
libs: [],
|
96
|
+
setup_path: nil,
|
97
|
+
chuser: nil,
|
98
|
+
chgroup: nil,
|
99
|
+
suppress_interval: 0,
|
100
|
+
suppress_repeated_stacktrace: true,
|
101
|
+
without_source: false,
|
102
|
+
use_v1_config: true,
|
103
|
+
supervise: true,
|
97
104
|
}
|
98
105
|
end
|
99
106
|
|
@@ -118,7 +125,7 @@ module Fluent
|
|
118
125
|
@suppress_config_dump = opt[:suppress_config_dump]
|
119
126
|
@without_source = opt[:without_source]
|
120
127
|
|
121
|
-
log_opts = {:
|
128
|
+
log_opts = {suppress_repeated_stacktrace: opt[:suppress_repeated_stacktrace]}
|
122
129
|
@log = LoggerInitializer.new(@log_path, @log_level, @chuser, @chgroup, log_opts)
|
123
130
|
@finished = false
|
124
131
|
@main_pid = nil
|
@@ -128,7 +135,7 @@ module Fluent
|
|
128
135
|
@log.init
|
129
136
|
show_plugin_config if @show_plugin_config
|
130
137
|
read_config
|
131
|
-
|
138
|
+
set_system_config
|
132
139
|
|
133
140
|
dry_run if @dry_run
|
134
141
|
start_daemonize if @daemonize
|
@@ -337,7 +344,7 @@ module Fluent
|
|
337
344
|
@main_pid = nil
|
338
345
|
ecode = $?.to_i
|
339
346
|
|
340
|
-
$log.info "process finished", :
|
347
|
+
$log.info "process finished", code: ecode
|
341
348
|
|
342
349
|
if !@finished && Time.now - start_time < 1
|
343
350
|
$log.warn "process died within 1 second. exit."
|
@@ -352,20 +359,20 @@ module Fluent
|
|
352
359
|
block.call
|
353
360
|
|
354
361
|
rescue Fluent::ConfigError
|
355
|
-
$log.error "config error", :
|
362
|
+
$log.error "config error", file: @config_path, error: $!.to_s
|
356
363
|
$log.debug_backtrace
|
357
364
|
unless @log.stdout?
|
358
365
|
console = Fluent::Log.new(STDOUT, @log_level).enable_debug
|
359
|
-
console.error "config error", :
|
366
|
+
console.error "config error", file: @config_path, error: $!.to_s
|
360
367
|
console.debug_backtrace
|
361
368
|
end
|
362
369
|
|
363
370
|
rescue
|
364
|
-
$log.error "unexpected error", :
|
371
|
+
$log.error "unexpected error", error: $!.to_s
|
365
372
|
$log.error_backtrace
|
366
373
|
unless @log.stdout?
|
367
374
|
console = Fluent::Log.new(STDOUT, @log_level).enable_debug
|
368
|
-
console.error "unexpected error", :
|
375
|
+
console.error "unexpected error", error: $!.to_s
|
369
376
|
console.error_backtrace
|
370
377
|
end
|
371
378
|
end
|
@@ -429,7 +436,7 @@ module Fluent
|
|
429
436
|
# in main thread during trap context
|
430
437
|
Thread.new {
|
431
438
|
read_config
|
432
|
-
|
439
|
+
set_system_config
|
433
440
|
if pid = @main_pid
|
434
441
|
Process.kill(:TERM, pid)
|
435
442
|
# don't resuce Erro::ESRSH here (invalid status)
|
@@ -454,7 +461,7 @@ module Fluent
|
|
454
461
|
end
|
455
462
|
|
456
463
|
def read_config
|
457
|
-
$log.info "reading config file", :
|
464
|
+
$log.info "reading config file", path: @config_path
|
458
465
|
@config_fname = File.basename(@config_path)
|
459
466
|
@config_basedir = File.dirname(@config_path)
|
460
467
|
@config_data = File.read(@config_path)
|
@@ -466,49 +473,9 @@ module Fluent
|
|
466
473
|
@conf = Fluent::Config.parse(@config_data, @config_fname, @config_basedir, @use_v1_config)
|
467
474
|
end
|
468
475
|
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
config_param :log_level, :default => nil do |level|
|
473
|
-
Log.str_to_level(level)
|
474
|
-
end
|
475
|
-
config_param :suppress_repeated_stacktrace, :bool, :default => nil
|
476
|
-
config_param :emit_error_log_interval, :time, :default => nil
|
477
|
-
config_param :suppress_config_dump, :bool, :default => nil
|
478
|
-
config_param :without_source, :bool, :default => nil
|
479
|
-
config_param :rpc_endpoint, :string, :default => nil
|
480
|
-
config_param :enable_get_dump, :bool, :default => nil
|
481
|
-
config_param :process_name, :default => nil
|
482
|
-
|
483
|
-
def initialize(conf)
|
484
|
-
super()
|
485
|
-
configure(conf)
|
486
|
-
end
|
487
|
-
|
488
|
-
def apply(supervisor)
|
489
|
-
system = self
|
490
|
-
supervisor.instance_eval {
|
491
|
-
@log.level = @log_level = system.log_level unless system.log_level.nil?
|
492
|
-
@suppress_interval = system.emit_error_log_interval unless system.emit_error_log_interval.nil?
|
493
|
-
@suppress_config_dump = system.suppress_config_dump unless system.suppress_config_dump.nil?
|
494
|
-
@suppress_repeated_stacktrace = system.suppress_repeated_stacktrace unless system.suppress_repeated_stacktrace.nil?
|
495
|
-
@without_source = system.without_source unless system.without_source.nil?
|
496
|
-
@rpc_endpoint = system.rpc_endpoint unless system.rpc_endpoint.nil?
|
497
|
-
@enable_get_dump = system.enable_get_dump unless system.enable_get_dump.nil?
|
498
|
-
@process_name = system.process_name unless system.process_name.nil?
|
499
|
-
}
|
500
|
-
end
|
501
|
-
end
|
502
|
-
|
503
|
-
# TODO: this method should be moved to SystemConfig class method
|
504
|
-
def apply_system_config
|
505
|
-
systems = @conf.elements.select { |e|
|
506
|
-
e.name == 'system'
|
507
|
-
}
|
508
|
-
return if systems.empty?
|
509
|
-
raise ConfigError, "<system> is duplicated. <system> should be only one" if systems.size > 1
|
510
|
-
|
511
|
-
SystemConfig.new(systems.first).apply(self)
|
476
|
+
def set_system_config
|
477
|
+
@system_config = SystemConfig.create(@conf) # @conf is set in read_config
|
478
|
+
@system_config.apply(self)
|
512
479
|
end
|
513
480
|
|
514
481
|
def run_configure
|
@@ -533,8 +500,7 @@ module Fluent
|
|
533
500
|
end
|
534
501
|
|
535
502
|
def init_engine
|
536
|
-
|
537
|
-
Fluent::Engine.init(init_opts)
|
503
|
+
Fluent::Engine.init(@system_config)
|
538
504
|
|
539
505
|
@libs.each {|lib|
|
540
506
|
require lib
|
@@ -0,0 +1,98 @@
|
|
1
|
+
#
|
2
|
+
# Fluent
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
#
|
16
|
+
|
17
|
+
require 'fluent/configurable'
|
18
|
+
require 'fluent/config/element'
|
19
|
+
|
20
|
+
module Fluent
|
21
|
+
module SystemConfigMixin
|
22
|
+
def system_config
|
23
|
+
@_system_config || Fluent::Engine.system_config
|
24
|
+
end
|
25
|
+
|
26
|
+
def system_config_override(opts={})
|
27
|
+
unless @_system_config
|
28
|
+
@_system_config = Fluent::Engine.system_config.dup
|
29
|
+
end
|
30
|
+
opts.each_pair do |key, value|
|
31
|
+
@_system_config.send(:"#{key.to_s}=", value)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
class SystemConfig
|
37
|
+
include Configurable
|
38
|
+
|
39
|
+
config_param :log_level, default: nil do |level|
|
40
|
+
Log.str_to_level(level)
|
41
|
+
end
|
42
|
+
config_param :suppress_repeated_stacktrace, :bool, default: nil
|
43
|
+
config_param :emit_error_log_interval, :time, default: nil
|
44
|
+
config_param :suppress_config_dump, :bool, default: nil
|
45
|
+
config_param :without_source, :bool, default: nil
|
46
|
+
config_param :rpc_endpoint, :string, default: nil
|
47
|
+
config_param :enable_get_dump, :bool, default: nil
|
48
|
+
config_param :process_name, default: nil
|
49
|
+
|
50
|
+
def self.create(conf)
|
51
|
+
systems = conf.elements.select { |e|
|
52
|
+
e.name == 'system'
|
53
|
+
}
|
54
|
+
return SystemConfig.new if systems.empty?
|
55
|
+
raise Fluent::ConfigError, "<system> is duplicated. <system> should be only one" if systems.size > 1
|
56
|
+
|
57
|
+
SystemConfig.new(systems.first)
|
58
|
+
end
|
59
|
+
|
60
|
+
def self.blank_system_config
|
61
|
+
Fluent::Config::Element.new('<SYSTEM>', '', {}, [])
|
62
|
+
end
|
63
|
+
|
64
|
+
def initialize(conf=nil)
|
65
|
+
super()
|
66
|
+
conf ||= SystemConfig.blank_system_config
|
67
|
+
configure(conf)
|
68
|
+
end
|
69
|
+
|
70
|
+
def dup
|
71
|
+
s = SystemConfig.new
|
72
|
+
s.log_level = @log_level
|
73
|
+
s.suppress_repeated_stacktrace = @suppress_repeated_stacktrace
|
74
|
+
s.emit_error_log_interval = @emit_error_log_interval
|
75
|
+
s.suppress_config_dump = @suppress_config_dump
|
76
|
+
s.without_source = @without_source
|
77
|
+
s.rpc_endpoint = @rpc_endpoint
|
78
|
+
s.enable_get_dump = @enable_get_dump
|
79
|
+
s.process_name = @process_name
|
80
|
+
|
81
|
+
s
|
82
|
+
end
|
83
|
+
|
84
|
+
def apply(supervisor)
|
85
|
+
system = self
|
86
|
+
supervisor.instance_eval {
|
87
|
+
@log.level = @log_level = system.log_level unless system.log_level.nil?
|
88
|
+
@suppress_interval = system.emit_error_log_interval unless system.emit_error_log_interval.nil?
|
89
|
+
@suppress_config_dump = system.suppress_config_dump unless system.suppress_config_dump.nil?
|
90
|
+
@suppress_repeated_stacktrace = system.suppress_repeated_stacktrace unless system.suppress_repeated_stacktrace.nil?
|
91
|
+
@without_source = system.without_source unless system.without_source.nil?
|
92
|
+
@rpc_endpoint = system.rpc_endpoint unless system.rpc_endpoint.nil?
|
93
|
+
@enable_get_dump = system.enable_get_dump unless system.enable_get_dump.nil?
|
94
|
+
@process_name = system.process_name unless system.process_name.nil?
|
95
|
+
}
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|