Skip to content

Commit 3d9d8ec

Browse files
committed
in_tail: add metrics to know file count monitored by TailWatcher
Signed-off-by: Shizuo Fujita <[email protected]>
1 parent eeb384e commit 3d9d8ec

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

lib/fluent/plugin/in_tail.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -814,6 +814,7 @@ def statistics
814814
'closed_file_count' => @metrics.closed.get,
815815
'rotated_file_count' => @metrics.rotated.get,
816816
'throttled_log_count' => @metrics.throttled.get,
817+
'tracking_file_count' => @tails.size,
817818
})
818819
}
819820
stats

test/plugin/test_in_tail.rb

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3443,4 +3443,42 @@ def test_next_rotation_occurs_very_fast_while_old_TW_still_waiting_rotate_wait
34433443
d.logs[-2..]
34443444
])
34453445
end
3446+
3447+
test 'statistics' do
3448+
config = config_element("", "", {
3449+
"tag" => "statistics",
3450+
"path" => "#{@tmp_dir}/statistics*.txt",
3451+
"format" => "none",
3452+
"read_from_head" => true,
3453+
})
3454+
Fluent::FileWrapper.open("#{@tmp_dir}/statistics1.txt", "w+") do |f|
3455+
f.puts "foo"
3456+
end
3457+
3458+
d = create_driver(config, false)
3459+
d.run(expect_records: 1, shutdown: false)
3460+
3461+
assert_equal({
3462+
"emit_records" => 0,
3463+
"emit_size" => 0,
3464+
"opened_file_count" => 1,
3465+
"closed_file_count" => 0,
3466+
"rotated_file_count" => 0,
3467+
"throttled_log_count" =>0,
3468+
"tracking_file_count" => 1,
3469+
},
3470+
d.instance.statistics["input"])
3471+
3472+
d.instance_shutdown
3473+
3474+
assert_equal({
3475+
"emit_records" => 0,
3476+
"emit_size" => 0,
3477+
"opened_file_count" => 1,
3478+
"closed_file_count" => 1,
3479+
"rotated_file_count" => 0,
3480+
"throttled_log_count" =>0,
3481+
"tracking_file_count" => 0,
3482+
},
3483+
d.instance.statistics["input"]) end
34463484
end

0 commit comments

Comments
 (0)