-
Notifications
You must be signed in to change notification settings - Fork 340
fix(otel-collector): fix log rotation script #1479
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
base: main
Are you sure you want to change the base?
fix(otel-collector): fix log rotation script #1479
Conversation
There were two issues with the log rotation script: 1. Logs could be lost since copying and then truncating the file might not finish before logs arrive. 2. The otel collector application will keeps the file handle and offset cached. After truncating, it will write starting at the last offset leaving the unallocated garbage in the beginning of the file. This garbage uses space. This commit moves the file instead of copying. That allows the collector to continue writing to the rolled file until a SIGHUP is sent. This causes a config refresh, which also opens a new log file. After, the rolled file and the new log file have correct sizes.
|
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
We don't have a changeset for these images so I just didn't add one. |
Code ReviewCritical Issues
Additional Concerns
RecommendationTest the SIGHUP timing thoroughly - the current implementation may work if collector handles SIGHUP quickly, but the race condition between file move and signal delivery could cause issues under load. |
E2E Test Results✅ All tests passed • 46 passed • 3 skipped • 262s
|
c7587a6 to
41f1bf3
Compare
…rotatorsh-does-not-truncate
brandon-pereira
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There were two issues with the log rotation script:
Logs could be lost since copying and then truncating the file might not finish before logs arrive.
The otel collector application will keeps the file handle and offset cached. After truncating, it will write starting at the last offset leaving the unallocated garbage in the beginning of the file. This garbage uses space.
This commit moves the file instead of copying. That allows the collector to continue writing to the rolled file until a SIGHUP is sent. This causes a config refresh, which also opens a new log file. After, the rolled file and the new log file have correct sizes.
--
ADDITIONAL NOTES:
Claude's code review is not accurate here.