Skip to content

Commit

Permalink
Remove unnecessary logging (#35426)
Browse files Browse the repository at this point in the history
* Remove unnecessary logging

The log line remove by this commit is unnecessary, it is not an actual
error in the sense something will not work. It only means the
harvester is already running for this file so another one does not
need to be started. Keeping this log line will only spam our log files
and make users worried.

* PR improvements

* Restoring the error context.
  • Loading branch information
belimawr authored May 11, 2023
1 parent 374a576 commit a070ea1
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions filebeat/input/filestream/internal/input-logfile/harvester.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,19 @@ func startHarvester(

harvesterCtx, cancelHarvester, err := hg.readers.newContext(srcID, canceler)
if err != nil {
// The returned may or not be collected by the caller, thus logging
// it here is important.
ctx.Logger.Errorf("error while adding new reader to the bookkeeper %v", err)
// The only possible returned error is ErrHarvesterAlreadyRunning, which is a normal
// behaviour of the Filestream input, it's not really an error, it's just an situation.
// If the harvester is already running we don't need to start a new one.
// At the moment of writing even the returned error is ignored. So the
// only real effect of this branch is to not start a second harvester.
//
// Currently the only places this error is checked is on task.Group and the
// only thing it does is to log the error. So to avoid unnecessary errors,
// we just return nil.
if errors.Is(err, ErrHarvesterAlreadyRunning) {
return nil
}

return fmt.Errorf("error while adding new reader to the bookkeeper %w", err)
}

Expand Down

0 comments on commit a070ea1

Please sign in to comment.