diff --git a/pkg/stanza/fileconsumer/internal/reader/factory.go b/pkg/stanza/fileconsumer/internal/reader/factory.go index c962f7d4b21f..a7934f4a9cbf 100644 --- a/pkg/stanza/fileconsumer/internal/reader/factory.go +++ b/pkg/stanza/fileconsumer/internal/reader/factory.go @@ -5,6 +5,7 @@ package reader // import "github.com/open-telemetry/opentelemetry-collector-cont import ( "bufio" + "fmt" "os" "time" @@ -73,9 +74,11 @@ func (f *Factory) NewReaderFromMetadata(file *os.File, m *Metadata) (r *Reader, r.lineSplitFunc = trim.WithFunc(trim.ToLength(flushFunc, f.MaxLogSize), f.TrimFunc) if !f.FromBeginning { - if err = r.offsetToEnd(); err != nil { - return nil, err + var info os.FileInfo + if info, err = r.file.Stat(); err != nil { + return nil, fmt.Errorf("stat: %w", err) } + r.Offset = info.Size() } r.emitFunc = f.EmitFunc diff --git a/pkg/stanza/fileconsumer/internal/reader/reader.go b/pkg/stanza/fileconsumer/internal/reader/reader.go index 7bd2311d8138..46ab06b222a0 100644 --- a/pkg/stanza/fileconsumer/internal/reader/reader.go +++ b/pkg/stanza/fileconsumer/internal/reader/reader.go @@ -7,7 +7,6 @@ import ( "bufio" "context" "errors" - "fmt" "os" "go.uber.org/zap" @@ -45,23 +44,6 @@ type Reader struct { deleteAtEOF bool } -// offsetToEnd sets the starting offset -func (r *Reader) offsetToEnd() error { - info, err := r.file.Stat() - if err != nil { - return fmt.Errorf("stat: %w", err) - } - r.Offset = info.Size() - return nil -} - -func (r *Reader) NewFingerprintFromFile() (*fingerprint.Fingerprint, error) { - if r.file == nil { - return nil, errors.New("file is nil") - } - return fingerprint.New(r.file, r.fingerprintSize) -} - // ReadToEnd will read until the end of the file func (r *Reader) ReadToEnd(ctx context.Context) { if _, err := r.file.Seek(r.Offset, 0); err != nil {