fluentd 1.13.3 → 1.16.5
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.
- checksums.yaml +4 -4
- data/.github/ISSUE_TEMPLATE/{bug_report.yaml → bug_report.yml} +2 -0
- data/.github/ISSUE_TEMPLATE/config.yml +2 -2
- data/.github/ISSUE_TEMPLATE/{feature_request.yaml → feature_request.yml} +1 -0
- data/.github/workflows/stale-actions.yml +11 -9
- data/.github/workflows/test.yml +32 -0
- data/CHANGELOG.md +490 -10
- data/CONTRIBUTING.md +2 -2
- data/MAINTAINERS.md +7 -5
- data/README.md +3 -23
- data/Rakefile +1 -1
- data/SECURITY.md +14 -0
- data/fluentd.gemspec +7 -8
- data/lib/fluent/command/cat.rb +13 -3
- data/lib/fluent/command/ctl.rb +6 -3
- data/lib/fluent/command/fluentd.rb +73 -65
- data/lib/fluent/command/plugin_config_formatter.rb +1 -1
- data/lib/fluent/compat/output.rb +9 -6
- data/lib/fluent/config/dsl.rb +1 -1
- data/lib/fluent/config/error.rb +12 -0
- data/lib/fluent/config/literal_parser.rb +2 -2
- data/lib/fluent/config/parser.rb +1 -1
- data/lib/fluent/config/v1_parser.rb +3 -3
- data/lib/fluent/config/yaml_parser/fluent_value.rb +47 -0
- data/lib/fluent/config/yaml_parser/loader.rb +108 -0
- data/lib/fluent/config/yaml_parser/parser.rb +166 -0
- data/lib/fluent/config/yaml_parser/section_builder.rb +107 -0
- data/lib/fluent/config/yaml_parser.rb +56 -0
- data/lib/fluent/config.rb +14 -1
- data/lib/fluent/counter/server.rb +1 -1
- data/lib/fluent/counter/validator.rb +3 -3
- data/lib/fluent/daemon.rb +2 -4
- data/lib/fluent/engine.rb +1 -1
- data/lib/fluent/env.rb +4 -0
- data/lib/fluent/error.rb +3 -0
- data/lib/fluent/event.rb +8 -4
- data/lib/fluent/event_router.rb +47 -2
- data/lib/fluent/file_wrapper.rb +137 -0
- data/lib/fluent/log/console_adapter.rb +66 -0
- data/lib/fluent/log.rb +44 -5
- data/lib/fluent/match.rb +1 -1
- data/lib/fluent/msgpack_factory.rb +6 -1
- data/lib/fluent/oj_options.rb +1 -2
- data/lib/fluent/plugin/bare_output.rb +49 -8
- data/lib/fluent/plugin/base.rb +26 -9
- data/lib/fluent/plugin/buf_file.rb +34 -5
- data/lib/fluent/plugin/buf_file_single.rb +32 -3
- data/lib/fluent/plugin/buffer/file_chunk.rb +1 -1
- data/lib/fluent/plugin/buffer.rb +216 -70
- data/lib/fluent/plugin/filter.rb +35 -1
- data/lib/fluent/plugin/filter_record_transformer.rb +1 -1
- data/lib/fluent/plugin/in_forward.rb +2 -2
- data/lib/fluent/plugin/in_http.rb +39 -10
- data/lib/fluent/plugin/in_monitor_agent.rb +4 -2
- data/lib/fluent/plugin/in_sample.rb +1 -1
- data/lib/fluent/plugin/in_syslog.rb +13 -1
- data/lib/fluent/plugin/in_tail/group_watch.rb +204 -0
- data/lib/fluent/plugin/in_tail/position_file.rb +33 -33
- data/lib/fluent/plugin/in_tail.rb +216 -84
- data/lib/fluent/plugin/in_tcp.rb +47 -2
- data/lib/fluent/plugin/input.rb +39 -1
- data/lib/fluent/plugin/metrics.rb +119 -0
- data/lib/fluent/plugin/metrics_local.rb +96 -0
- data/lib/fluent/plugin/multi_output.rb +43 -6
- data/lib/fluent/plugin/out_copy.rb +1 -1
- data/lib/fluent/plugin/out_exec_filter.rb +2 -2
- data/lib/fluent/plugin/out_file.rb +20 -2
- data/lib/fluent/plugin/out_forward/ack_handler.rb +19 -4
- data/lib/fluent/plugin/out_forward/socket_cache.rb +2 -0
- data/lib/fluent/plugin/out_forward.rb +17 -9
- data/lib/fluent/plugin/out_secondary_file.rb +39 -22
- data/lib/fluent/plugin/output.rb +167 -78
- data/lib/fluent/plugin/parser.rb +3 -4
- data/lib/fluent/plugin/parser_apache2.rb +1 -1
- data/lib/fluent/plugin/parser_json.rb +1 -1
- data/lib/fluent/plugin/parser_syslog.rb +1 -1
- data/lib/fluent/plugin/storage_local.rb +3 -5
- data/lib/fluent/plugin.rb +10 -1
- data/lib/fluent/plugin_helper/child_process.rb +3 -0
- data/lib/fluent/plugin_helper/event_emitter.rb +8 -1
- data/lib/fluent/plugin_helper/event_loop.rb +2 -2
- data/lib/fluent/plugin_helper/http_server/server.rb +2 -1
- data/lib/fluent/plugin_helper/metrics.rb +129 -0
- data/lib/fluent/plugin_helper/record_accessor.rb +1 -1
- data/lib/fluent/plugin_helper/retry_state.rb +14 -4
- data/lib/fluent/plugin_helper/server.rb +35 -6
- data/lib/fluent/plugin_helper/service_discovery.rb +2 -2
- data/lib/fluent/plugin_helper/socket.rb +13 -2
- data/lib/fluent/plugin_helper/thread.rb +3 -3
- data/lib/fluent/plugin_helper.rb +1 -0
- data/lib/fluent/plugin_id.rb +3 -2
- data/lib/fluent/registry.rb +2 -1
- data/lib/fluent/root_agent.rb +6 -0
- data/lib/fluent/rpc.rb +4 -3
- data/lib/fluent/supervisor.rb +283 -259
- data/lib/fluent/system_config.rb +13 -3
- data/lib/fluent/test/driver/base.rb +11 -5
- data/lib/fluent/test/driver/filter.rb +4 -0
- data/lib/fluent/test/startup_shutdown.rb +6 -8
- data/lib/fluent/time.rb +21 -20
- data/lib/fluent/version.rb +1 -1
- data/lib/fluent/win32api.rb +38 -0
- data/lib/fluent/winsvc.rb +5 -8
- data/templates/new_gem/test/helper.rb.erb +0 -1
- data/test/command/test_cat.rb +31 -2
- data/test/command/test_ctl.rb +1 -2
- data/test/command/test_fluentd.rb +209 -24
- data/test/command/test_plugin_config_formatter.rb +0 -1
- data/test/compat/test_parser.rb +6 -6
- data/test/config/test_system_config.rb +13 -11
- data/test/config/test_types.rb +1 -1
- data/test/log/test_console_adapter.rb +110 -0
- data/test/plugin/in_tail/test_io_handler.rb +26 -8
- data/test/plugin/in_tail/test_position_file.rb +48 -59
- data/test/plugin/out_forward/test_ack_handler.rb +39 -0
- data/test/plugin/out_forward/test_socket_cache.rb +26 -1
- data/test/plugin/test_bare_output.rb +14 -1
- data/test/plugin/test_base.rb +133 -1
- data/test/plugin/test_buf_file.rb +62 -23
- data/test/plugin/test_buf_file_single.rb +65 -0
- data/test/plugin/test_buffer.rb +267 -3
- data/test/plugin/test_buffer_chunk.rb +11 -0
- data/test/plugin/test_filter.rb +12 -1
- data/test/plugin/test_filter_parser.rb +1 -1
- data/test/plugin/test_filter_stdout.rb +2 -2
- data/test/plugin/test_in_forward.rb +9 -11
- data/test/plugin/test_in_http.rb +65 -3
- data/test/plugin/test_in_monitor_agent.rb +216 -11
- data/test/plugin/test_in_object_space.rb +9 -3
- data/test/plugin/test_in_syslog.rb +35 -0
- data/test/plugin/test_in_tail.rb +1393 -385
- data/test/plugin/test_in_tcp.rb +87 -2
- data/test/plugin/test_in_udp.rb +28 -0
- data/test/plugin/test_in_unix.rb +2 -2
- data/test/plugin/test_input.rb +12 -1
- data/test/plugin/test_metrics.rb +294 -0
- data/test/plugin/test_metrics_local.rb +96 -0
- data/test/plugin/test_multi_output.rb +25 -1
- data/test/plugin/test_out_exec.rb +6 -4
- data/test/plugin/test_out_exec_filter.rb +6 -2
- data/test/plugin/test_out_file.rb +34 -17
- data/test/plugin/test_out_forward.rb +78 -77
- data/test/plugin/test_out_http.rb +1 -0
- data/test/plugin/test_out_stdout.rb +2 -2
- data/test/plugin/test_output.rb +297 -12
- data/test/plugin/test_output_as_buffered.rb +44 -44
- data/test/plugin/test_output_as_buffered_compress.rb +32 -18
- data/test/plugin/test_output_as_buffered_retries.rb +54 -7
- data/test/plugin/test_output_as_buffered_secondary.rb +4 -4
- data/test/plugin/test_parser_regexp.rb +1 -6
- data/test/plugin/test_parser_syslog.rb +1 -1
- data/test/plugin_helper/test_cert_option.rb +1 -1
- data/test/plugin_helper/test_child_process.rb +38 -16
- data/test/plugin_helper/test_event_emitter.rb +29 -0
- data/test/plugin_helper/test_http_server_helper.rb +1 -1
- data/test/plugin_helper/test_metrics.rb +137 -0
- data/test/plugin_helper/test_retry_state.rb +602 -38
- data/test/plugin_helper/test_server.rb +78 -6
- data/test/plugin_helper/test_timer.rb +2 -2
- data/test/test_config.rb +191 -24
- data/test/test_event_router.rb +17 -0
- data/test/test_file_wrapper.rb +53 -0
- data/test/test_formatter.rb +24 -21
- data/test/test_log.rb +122 -40
- data/test/test_msgpack_factory.rb +32 -0
- data/test/test_plugin_classes.rb +102 -0
- data/test/test_root_agent.rb +30 -1
- data/test/test_supervisor.rb +477 -257
- data/test/test_time_parser.rb +22 -0
- metadata +55 -34
- data/.drone.yml +0 -35
- data/.github/workflows/issue-auto-closer.yml +0 -12
- data/.github/workflows/linux-test.yaml +0 -36
- data/.github/workflows/macos-test.yaml +0 -30
- data/.github/workflows/windows-test.yaml +0 -46
- data/.gitlab-ci.yml +0 -103
- data/lib/fluent/plugin/file_wrapper.rb +0 -187
- data/test/plugin/test_file_wrapper.rb +0 -126
- data/test/test_logger_initializer.rb +0 -46
data/test/test_log.rb
CHANGED
|
@@ -4,13 +4,17 @@ require 'fluent/engine'
|
|
|
4
4
|
require 'fluent/log'
|
|
5
5
|
require 'timecop'
|
|
6
6
|
require 'logger'
|
|
7
|
+
require 'securerandom'
|
|
8
|
+
require 'pathname'
|
|
7
9
|
|
|
8
10
|
class LogTest < Test::Unit::TestCase
|
|
9
|
-
|
|
11
|
+
def tmp_dir
|
|
12
|
+
File.join(File.dirname(__FILE__), "tmp", "log", "#{ENV['TEST_ENV_NUMBER']}", SecureRandom.hex(10))
|
|
13
|
+
end
|
|
10
14
|
|
|
11
15
|
def setup
|
|
12
|
-
|
|
13
|
-
FileUtils.mkdir_p(
|
|
16
|
+
@tmp_dir = tmp_dir
|
|
17
|
+
FileUtils.mkdir_p(@tmp_dir)
|
|
14
18
|
@log_device = Fluent::Test::DummyLogDevice.new
|
|
15
19
|
@timestamp = Time.parse("2016-04-21 02:58:41 +0000")
|
|
16
20
|
@timestamp_str = @timestamp.strftime("%Y-%m-%d %H:%M:%S %z")
|
|
@@ -21,6 +25,21 @@ class LogTest < Test::Unit::TestCase
|
|
|
21
25
|
@log_device.reset
|
|
22
26
|
Timecop.return
|
|
23
27
|
Thread.current[:last_repeated_stacktrace] = nil
|
|
28
|
+
begin
|
|
29
|
+
FileUtils.rm_rf(@tmp_dir)
|
|
30
|
+
rescue Errno::EACCES
|
|
31
|
+
# It may occur on Windows because of delete pending state due to delayed GC.
|
|
32
|
+
# Ruby 3.2 or later doesn't ignore Errno::EACCES:
|
|
33
|
+
# https://github.com/ruby/ruby/commit/983115cf3c8f75b1afbe3274f02c1529e1ce3a81
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def test_per_process_path
|
|
38
|
+
path = Fluent::Log.per_process_path("C:/tmp/test.log", :supervisor, 0)
|
|
39
|
+
assert_equal(path, "C:/tmp/test-supervisor-0.log")
|
|
40
|
+
|
|
41
|
+
path = Fluent::Log.per_process_path("C:/tmp/test.log", :worker, 1)
|
|
42
|
+
assert_equal(path, "C:/tmp/test-1.log")
|
|
24
43
|
end
|
|
25
44
|
|
|
26
45
|
sub_test_case "log level" do
|
|
@@ -453,6 +472,43 @@ class LogTest < Test::Unit::TestCase
|
|
|
453
472
|
]
|
|
454
473
|
assert_equal(expected, log.out.logs)
|
|
455
474
|
end
|
|
475
|
+
|
|
476
|
+
def test_reject_on_max_size
|
|
477
|
+
ignore_same_log_interval = 10
|
|
478
|
+
|
|
479
|
+
logger = Fluent::Log.new(
|
|
480
|
+
ServerEngine::DaemonLogger.new(@log_device, log_level: ServerEngine::DaemonLogger::INFO),
|
|
481
|
+
ignore_same_log_interval: ignore_same_log_interval,
|
|
482
|
+
)
|
|
483
|
+
|
|
484
|
+
# Output unique log every second.
|
|
485
|
+
Fluent::Log::IGNORE_SAME_LOG_MAX_CACHE_SIZE.times do |i|
|
|
486
|
+
logger.info "Test #{i}"
|
|
487
|
+
Timecop.freeze(@timestamp + i)
|
|
488
|
+
end
|
|
489
|
+
logger.info "Over max size!"
|
|
490
|
+
|
|
491
|
+
# The newest cache and the latest caches in `ignore_same_log_interval` should exist.
|
|
492
|
+
assert { Thread.current[:last_same_log].size == ignore_same_log_interval + 1 }
|
|
493
|
+
end
|
|
494
|
+
|
|
495
|
+
def test_clear_on_max_size
|
|
496
|
+
ignore_same_log_interval = 10
|
|
497
|
+
|
|
498
|
+
logger = Fluent::Log.new(
|
|
499
|
+
ServerEngine::DaemonLogger.new(@log_device, log_level: ServerEngine::DaemonLogger::INFO),
|
|
500
|
+
ignore_same_log_interval: ignore_same_log_interval,
|
|
501
|
+
)
|
|
502
|
+
|
|
503
|
+
# Output unique log at the same time.
|
|
504
|
+
Fluent::Log::IGNORE_SAME_LOG_MAX_CACHE_SIZE.times do |i|
|
|
505
|
+
logger.info "Test #{i}"
|
|
506
|
+
end
|
|
507
|
+
logger.info "Over max size!"
|
|
508
|
+
|
|
509
|
+
# Can't reject old logs, so all cache should be cleared and only the newest should exist.
|
|
510
|
+
assert { Thread.current[:last_same_log].size == 1 }
|
|
511
|
+
end
|
|
456
512
|
end
|
|
457
513
|
|
|
458
514
|
def test_dup
|
|
@@ -560,7 +616,7 @@ class LogTest < Test::Unit::TestCase
|
|
|
560
616
|
Timecop.freeze(@timestamp)
|
|
561
617
|
|
|
562
618
|
rotate_age, rotate_size, travel_term = expected
|
|
563
|
-
path = "#{
|
|
619
|
+
path = "#{@tmp_dir}/log-dev-io-#{rotate_size}-#{rotate_age}"
|
|
564
620
|
|
|
565
621
|
logdev = Fluent::LogDeviceIO.new(path, shift_age: rotate_age, shift_size: rotate_size)
|
|
566
622
|
logger = ServerEngine::DaemonLogger.new(logdev)
|
|
@@ -583,45 +639,71 @@ class LogTest < Test::Unit::TestCase
|
|
|
583
639
|
|
|
584
640
|
def test_log_rotates_specified_size_with_logdevio
|
|
585
641
|
with_timezone('utc') do
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
642
|
+
begin
|
|
643
|
+
rotate_age = 2
|
|
644
|
+
rotate_size = 100
|
|
645
|
+
path = "#{@tmp_dir}/log-dev-io-#{rotate_size}-#{rotate_age}"
|
|
646
|
+
path0 = path + '.0'
|
|
647
|
+
path1 = path + '.1'
|
|
648
|
+
|
|
649
|
+
logdev = Fluent::LogDeviceIO.new(path, shift_age: rotate_age, shift_size: rotate_size)
|
|
650
|
+
logger = ServerEngine::DaemonLogger.new(logdev)
|
|
651
|
+
log = Fluent::Log.new(logger)
|
|
652
|
+
|
|
653
|
+
msg = 'a' * 101
|
|
654
|
+
log.info msg
|
|
655
|
+
assert_match msg, File.read(path)
|
|
656
|
+
assert_true File.exist?(path)
|
|
657
|
+
assert_true !File.exist?(path0)
|
|
658
|
+
assert_true !File.exist?(path1)
|
|
659
|
+
|
|
660
|
+
# create log.0
|
|
661
|
+
msg2 = 'b' * 101
|
|
662
|
+
log.info msg2
|
|
663
|
+
c = File.read(path)
|
|
664
|
+
c0 = File.read(path0)
|
|
665
|
+
assert_match msg2, c
|
|
666
|
+
assert_match msg, c0
|
|
667
|
+
assert_true File.exist?(path)
|
|
668
|
+
assert_true File.exist?(path0)
|
|
669
|
+
assert_true !File.exist?(path1)
|
|
670
|
+
|
|
671
|
+
# rotate
|
|
672
|
+
msg3 = 'c' * 101
|
|
673
|
+
log.info msg3
|
|
674
|
+
c = File.read(path)
|
|
675
|
+
c0 = File.read(path0)
|
|
676
|
+
assert_match msg3, c
|
|
677
|
+
assert_match msg2, c0
|
|
678
|
+
assert_true File.exist?(path)
|
|
679
|
+
assert_true File.exist?(path0)
|
|
680
|
+
assert_true !File.exist?(path1)
|
|
681
|
+
ensure
|
|
682
|
+
logdev&.close
|
|
683
|
+
end
|
|
684
|
+
end
|
|
685
|
+
end
|
|
591
686
|
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
log = Fluent::Log.new(logger)
|
|
687
|
+
def test_reopen
|
|
688
|
+
path = Pathname(@tmp_dir) + "fluent.log"
|
|
595
689
|
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
assert_true File.exist?(path)
|
|
600
|
-
assert_true !File.exist?(path0)
|
|
601
|
-
assert_true !File.exist?(path1)
|
|
690
|
+
logdev = Fluent::LogDeviceIO.new(path.to_s)
|
|
691
|
+
logger = ServerEngine::DaemonLogger.new(logdev)
|
|
692
|
+
log = Fluent::Log.new(logger, path: path)
|
|
602
693
|
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
log.info msg3
|
|
617
|
-
c = File.read(path)
|
|
618
|
-
c0 = File.read(path0)
|
|
619
|
-
assert_match msg3, c
|
|
620
|
-
assert_match msg2, c0
|
|
621
|
-
assert_true File.exist?(path)
|
|
622
|
-
assert_true File.exist?(path0)
|
|
623
|
-
assert_true !File.exist?(path1)
|
|
624
|
-
end
|
|
694
|
+
message = "This is test message."
|
|
695
|
+
|
|
696
|
+
log.info message
|
|
697
|
+
log.reopen!
|
|
698
|
+
log.info message
|
|
699
|
+
|
|
700
|
+
assert { path.read.lines.count{ |line| line.include?(message) } == 2 }
|
|
701
|
+
# Assert reopening the same file.
|
|
702
|
+
# Especially, on Windows, the filepath is fixed for each process with rotate,
|
|
703
|
+
# so we need to care about this.
|
|
704
|
+
assert { path.parent.entries.size == 3 } # [".", "..", "fluent.log"]
|
|
705
|
+
ensure
|
|
706
|
+
logdev&.close
|
|
625
707
|
end
|
|
626
708
|
end
|
|
627
709
|
|
|
@@ -15,4 +15,36 @@ class MessagePackFactoryTest < Test::Unit::TestCase
|
|
|
15
15
|
assert mp.msgpack_factory
|
|
16
16
|
assert mp.msgpack_factory
|
|
17
17
|
end
|
|
18
|
+
|
|
19
|
+
sub_test_case 'thread_local_msgpack_packer' do
|
|
20
|
+
test 'packer is cached' do
|
|
21
|
+
packer1 = Fluent::MessagePackFactory.thread_local_msgpack_packer
|
|
22
|
+
packer2 = Fluent::MessagePackFactory.thread_local_msgpack_packer
|
|
23
|
+
assert_equal packer1, packer2
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
sub_test_case 'thread_local_msgpack_unpacker' do
|
|
28
|
+
test 'unpacker is cached' do
|
|
29
|
+
unpacker1 = Fluent::MessagePackFactory.thread_local_msgpack_unpacker
|
|
30
|
+
unpacker2 = Fluent::MessagePackFactory.thread_local_msgpack_unpacker
|
|
31
|
+
assert_equal unpacker1, unpacker2
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# We need to reset the buffer every time so that received incomplete data
|
|
35
|
+
# must not affect data from other senders.
|
|
36
|
+
test 'reset the internal buffer of unpacker every time' do
|
|
37
|
+
unpacker1 = Fluent::MessagePackFactory.thread_local_msgpack_unpacker
|
|
38
|
+
unpacker1.feed_each("\xA6foo") do |result|
|
|
39
|
+
flunk("This callback must not be called since the data is uncomplete.")
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
records = []
|
|
43
|
+
unpacker2 = Fluent::MessagePackFactory.thread_local_msgpack_unpacker
|
|
44
|
+
unpacker2.feed_each("\xA3foo") do |result|
|
|
45
|
+
records.append(result)
|
|
46
|
+
end
|
|
47
|
+
assert_equal ["foo"], records
|
|
48
|
+
end
|
|
49
|
+
end
|
|
18
50
|
end
|
data/test/test_plugin_classes.rb
CHANGED
|
@@ -5,11 +5,78 @@ require 'fluent/plugin/bare_output'
|
|
|
5
5
|
require 'fluent/plugin/filter'
|
|
6
6
|
|
|
7
7
|
module FluentTest
|
|
8
|
+
class FluentTestCounterMetrics < Fluent::Plugin::Metrics
|
|
9
|
+
Fluent::Plugin.register_metrics('test_counter', self)
|
|
10
|
+
|
|
11
|
+
attr_reader :data
|
|
12
|
+
|
|
13
|
+
def initialize
|
|
14
|
+
super
|
|
15
|
+
@data = 0
|
|
16
|
+
end
|
|
17
|
+
def get
|
|
18
|
+
@data
|
|
19
|
+
end
|
|
20
|
+
def inc
|
|
21
|
+
@data +=1
|
|
22
|
+
end
|
|
23
|
+
def add(value)
|
|
24
|
+
@data += value
|
|
25
|
+
end
|
|
26
|
+
def set(value)
|
|
27
|
+
@data = value
|
|
28
|
+
end
|
|
29
|
+
def close
|
|
30
|
+
@data = 0
|
|
31
|
+
super
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
class FluentTestGaugeMetrics < Fluent::Plugin::Metrics
|
|
36
|
+
Fluent::Plugin.register_metrics('test_gauge', self)
|
|
37
|
+
|
|
38
|
+
attr_reader :data
|
|
39
|
+
|
|
40
|
+
def initialize
|
|
41
|
+
super
|
|
42
|
+
@data = 0
|
|
43
|
+
end
|
|
44
|
+
def get
|
|
45
|
+
@data
|
|
46
|
+
end
|
|
47
|
+
def inc
|
|
48
|
+
@data += 1
|
|
49
|
+
end
|
|
50
|
+
def dec
|
|
51
|
+
@data -=1
|
|
52
|
+
end
|
|
53
|
+
def add(value)
|
|
54
|
+
@data += value
|
|
55
|
+
end
|
|
56
|
+
def sub(value)
|
|
57
|
+
@data -= value
|
|
58
|
+
end
|
|
59
|
+
def set(value)
|
|
60
|
+
@data = value
|
|
61
|
+
end
|
|
62
|
+
def close
|
|
63
|
+
@data = 0
|
|
64
|
+
super
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
|
|
8
68
|
class FluentTestInput < ::Fluent::Plugin::Input
|
|
9
69
|
::Fluent::Plugin.register_input('test_in', self)
|
|
10
70
|
|
|
11
71
|
attr_reader :started
|
|
12
72
|
|
|
73
|
+
def initialize
|
|
74
|
+
super
|
|
75
|
+
# stub metrics instances
|
|
76
|
+
@emit_records_metrics = FluentTest::FluentTestCounterMetrics.new
|
|
77
|
+
@emit_size_metrics = FluentTest::FluentTestCounterMetrics.new
|
|
78
|
+
end
|
|
79
|
+
|
|
13
80
|
def start
|
|
14
81
|
super
|
|
15
82
|
@started = true
|
|
@@ -28,6 +95,13 @@ module FluentTest
|
|
|
28
95
|
|
|
29
96
|
config_param :num, :integer, default: 10000
|
|
30
97
|
|
|
98
|
+
def initialize
|
|
99
|
+
super
|
|
100
|
+
# stub metrics instances
|
|
101
|
+
@emit_records_metrics = FluentTest::FluentTestCounterMetrics.new
|
|
102
|
+
@emit_size_metrics = FluentTest::FluentTestCounterMetrics.new
|
|
103
|
+
end
|
|
104
|
+
|
|
31
105
|
def start
|
|
32
106
|
super
|
|
33
107
|
@started = true
|
|
@@ -49,6 +123,15 @@ module FluentTest
|
|
|
49
123
|
def initialize
|
|
50
124
|
super
|
|
51
125
|
@events = Hash.new { |h, k| h[k] = [] }
|
|
126
|
+
# stub metrics instances
|
|
127
|
+
@num_errors_metrics = FluentTest::FluentTestCounterMetrics.new
|
|
128
|
+
@emit_count_metrics = FluentTest::FluentTestCounterMetrics.new
|
|
129
|
+
@emit_records_metrics = FluentTest::FluentTestCounterMetrics.new
|
|
130
|
+
@emit_size_metrics = FluentTest::FluentTestCounterMetrics.new
|
|
131
|
+
@write_count_metrics = FluentTest::FluentTestCounterMetrics.new
|
|
132
|
+
@rollback_count_metrics = FluentTest::FluentTestCounterMetrics.new
|
|
133
|
+
@flush_time_count_metrics = FluentTest::FluentTestCounterMetrics.new
|
|
134
|
+
@slow_flush_count_metrics = FluentTest::FluentTestCounterMetrics.new
|
|
52
135
|
end
|
|
53
136
|
|
|
54
137
|
attr_reader :events
|
|
@@ -168,6 +251,19 @@ module FluentTest
|
|
|
168
251
|
class FluentTestErrorOutput < ::Fluent::Plugin::Output
|
|
169
252
|
::Fluent::Plugin.register_output('test_out_error', self)
|
|
170
253
|
|
|
254
|
+
def initialize
|
|
255
|
+
super
|
|
256
|
+
# stub metrics instances
|
|
257
|
+
@num_errors_metrics = FluentTest::FluentTestCounterMetrics.new
|
|
258
|
+
@emit_count_metrics = FluentTest::FluentTestCounterMetrics.new
|
|
259
|
+
@emit_records_metrics = FluentTest::FluentTestCounterMetrics.new
|
|
260
|
+
@emit_size_metrics = FluentTest::FluentTestCounterMetrics.new
|
|
261
|
+
@write_count_metrics = FluentTest::FluentTestCounterMetrics.new
|
|
262
|
+
@rollback_count_metrics = FluentTest::FluentTestCounterMetrics.new
|
|
263
|
+
@flush_time_count_metrics = FluentTest::FluentTestCounterMetrics.new
|
|
264
|
+
@slow_flush_count_metrics = FluentTest::FluentTestCounterMetrics.new
|
|
265
|
+
end
|
|
266
|
+
|
|
171
267
|
def format(tag, time, record)
|
|
172
268
|
raise "emit error!"
|
|
173
269
|
end
|
|
@@ -184,6 +280,9 @@ module FluentTest
|
|
|
184
280
|
super()
|
|
185
281
|
@num = 0
|
|
186
282
|
@field = field
|
|
283
|
+
# stub metrics instances
|
|
284
|
+
@emit_records_metrics = FluentTest::FluentTestCounterMetrics.new
|
|
285
|
+
@emit_size_metrics = FluentTest::FluentTestCounterMetrics.new
|
|
187
286
|
end
|
|
188
287
|
|
|
189
288
|
attr_reader :num
|
|
@@ -213,6 +312,9 @@ module FluentTest
|
|
|
213
312
|
super()
|
|
214
313
|
@num = 0
|
|
215
314
|
@field = field
|
|
315
|
+
# stub metrics instances
|
|
316
|
+
@emit_records_metrics = FluentTest::FluentTestCounterMetrics.new
|
|
317
|
+
@emit_size_metrics = FluentTest::FluentTestCounterMetrics.new
|
|
216
318
|
end
|
|
217
319
|
|
|
218
320
|
attr_reader :num
|
data/test/test_root_agent.rb
CHANGED
|
@@ -16,7 +16,8 @@ class RootAgentTest < ::Test::Unit::TestCase
|
|
|
16
16
|
|
|
17
17
|
data(
|
|
18
18
|
'suppress interval' => [{'emit_error_log_interval' => 30}, {:@suppress_emit_error_log_interval => 30}],
|
|
19
|
-
'without source' => [{'without_source' => true}, {:@without_source => true}]
|
|
19
|
+
'without source' => [{'without_source' => true}, {:@without_source => true}],
|
|
20
|
+
'enable input metrics' => [{'enable_input_metrics' => true}, {:@enable_input_metrics => true}],
|
|
20
21
|
)
|
|
21
22
|
def test_initialize_with_opt(data)
|
|
22
23
|
opt, expected = data
|
|
@@ -109,6 +110,34 @@ EOC
|
|
|
109
110
|
end
|
|
110
111
|
end
|
|
111
112
|
|
|
113
|
+
test 'raises configuration error for label without name' do
|
|
114
|
+
conf = <<-EOC
|
|
115
|
+
<label>
|
|
116
|
+
@type test_out
|
|
117
|
+
</label>
|
|
118
|
+
EOC
|
|
119
|
+
errmsg = "Missing symbol argument on <label> directive"
|
|
120
|
+
assert_raise Fluent::ConfigError.new(errmsg) do
|
|
121
|
+
configure_ra(conf)
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
test 'raises configuration error for <label @ROOT>' do
|
|
126
|
+
conf = <<-EOC
|
|
127
|
+
<source>
|
|
128
|
+
@type test_in
|
|
129
|
+
@label @ROOT
|
|
130
|
+
</source>
|
|
131
|
+
<label @ROOT>
|
|
132
|
+
@type test_out
|
|
133
|
+
</label>
|
|
134
|
+
EOC
|
|
135
|
+
errmsg = "@ROOT for <label> is not permitted, reserved for getting root router"
|
|
136
|
+
assert_raise Fluent::ConfigError.new(errmsg) do
|
|
137
|
+
configure_ra(conf)
|
|
138
|
+
end
|
|
139
|
+
end
|
|
140
|
+
|
|
112
141
|
test 'raises configuration error if there are not match sections in label section' do
|
|
113
142
|
conf = <<-EOC
|
|
114
143
|
<source>
|