Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix reading partial logs in active files #21

Merged
merged 1 commit into from
Jul 13, 2020

Conversation

camdencheek
Copy link
Contributor

@camdencheek camdencheek commented Jul 10, 2020

Description of Changes

When logs are actively being written to, we can't assume that an EOF
is a valid log entry terminator since the application writing could
have written a partial entry.

This commit changes our logic so we only read to the end of the file
if both the offset and the file size haven't changed since the last time
we polled. This gives applications as long as the poll interval to write
an entire log entry.

Description of Changes

Please check that the PR fulfills these requirements

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)
  • Add a changelog entry (for non-trivial bug fixes / features)
  • CI passes

When logs are actively being written to, we can't assume that an EOF
is a valid log entry terminator since the application writing could
have written a partial entry.

This commit changes our logic so we only read to the end of the file
if both the offset and the file size haven't changed since the last time
we polled. This gives applications as long as the poll interval to write
an entire log entry.
@camdencheek camdencheek requested a review from jmwilliams89 July 10, 2020 21:02
@codecov
Copy link

codecov bot commented Jul 10, 2020

Codecov Report

Merging #21 into master will increase coverage by 0.04%.
The diff coverage is 81.82%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #21      +/-   ##
==========================================
+ Coverage   75.62%   75.66%   +0.04%     
==========================================
  Files          61       61              
  Lines        3601     3632      +31     
==========================================
+ Hits         2723     2748      +25     
- Misses        654      658       +4     
- Partials      224      226       +2     
Impacted Files Coverage Δ
plugin/builtin/input/file/read_to_end.go 68.85% <62.50%> (-2.89%) ⬇️
plugin/builtin/input/file/line_splitter.go 95.45% <83.33%> (+0.86%) ⬆️
plugin/builtin/input/file/file.go 79.45% <100.00%> (+0.65%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 445baac...0ccb4bb. Read the comment docs.

@camdencheek camdencheek merged commit f42e8b7 into master Jul 13, 2020
@camdencheek camdencheek deleted the file-input-active-reads branch July 13, 2020 13:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants