Skip to content

Commit

Permalink
update sync time
Browse files Browse the repository at this point in the history
  • Loading branch information
wildum committed Dec 13, 2024
1 parent 27cee0f commit af2e674
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions internal/component/loki/source/file/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,9 @@ func (c *Component) Run(ctx context.Context) error {
c.mut.RUnlock()
}()

// Check every 2 seconds for readers that were stopped
// Check every 5 seconds for readers that were stopped
// Should we have a parameter for this?
ticker := time.NewTicker(2 * time.Second)
ticker := time.NewTicker(5 * time.Second)
defer ticker.Stop()

for {
Expand All @@ -159,7 +159,7 @@ func (c *Component) Run(ctx context.Context) error {
}
c.mut.RUnlock()
case <-ticker.C:
c.mut.RLock()
c.mut.Lock()
// Find readers that are stopped and re-create them if the files that they were tailing are back.
// This helps for log rotation on Windows because the tailer is closed as soon as the file is removed.
// On Unix-like systems, it won't re-create any reader because the reader will stay open till the next Update call.
Expand All @@ -179,7 +179,7 @@ func (c *Component) Run(ctx context.Context) error {
delete(c.readers, key)
c.addReader(key, reader.Path(), reader.Labels())
}
c.mut.RUnlock()
c.mut.Unlock()
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion internal/component/loki/source/file/file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ func TestDeleteRecreateFile(t *testing.T) {
require.WithinDuration(t, time.Now(), logEntry.Timestamp, 1*time.Second)
require.Equal(t, "writing some new text", logEntry.Line)
require.Equal(t, wantLabelSet, logEntry.Labels)
case <-time.After(5 * time.Second):
case <-time.After(10 * time.Second):
require.FailNow(t, "failed waiting for log line")
}
}

0 comments on commit af2e674

Please sign in to comment.