Skip to content
Merged
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
16 changes: 12 additions & 4 deletions test/plugin/test_in_tail.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2769,10 +2769,18 @@ def test_lines_collected_with_no_throttling(data)
sleep_interval = 0.1
tail_watcher_interval = 1.0 # hard coded value in in_tail
safety_ratio = 1.2
lower_jitter = sleep_interval * safety_ratio
upper_jitter = (tail_watcher_interval + sleep_interval) * safety_ratio
lower_interval = rate_period - lower_jitter
upper_interval = rate_period + upper_jitter
# The throttling guarantees that consecutive *read starts* are at least
# rate_period apart. However, this test measures the interval between
# *emit* events, and an emit happens after a whole batch (= `limit` lines,
# ~8MB here) has been read, i.e. at `read_start + read_duration`. Since the
# read duration varies per batch (especially the first batch right after
# the file is opened), the measured emit interval can deviate from
# rate_period in either direction by roughly the same magnitude as the
# watcher scheduling delay. Use a symmetric jitter so the lower bound also
# tolerates this read/observation latency.
jitter = (tail_watcher_interval + sleep_interval) * safety_ratio
lower_interval = rate_period - jitter
upper_interval = rate_period + jitter

emit_count = 0
prev_count = 0
Expand Down
Loading