diff --git a/pkg/stanza/fileconsumer/config.go b/pkg/stanza/fileconsumer/config.go index 376f3c86c6ee..b2355adafc46 100644 --- a/pkg/stanza/fileconsumer/config.go +++ b/pkg/stanza/fileconsumer/config.go @@ -100,7 +100,7 @@ func (c Config) Build(logger *zap.SugaredLogger, emit emit.Callback) (*Manager, } // Ensure that splitter is buildable - factory := splitter.NewMultilineFactory(c.SplitConfig, enc, int(c.MaxLogSize), c.TrimConfig.Func(), c.FlushPeriod) + factory := splitter.NewSplitFuncFactory(c.SplitConfig, enc, int(c.MaxLogSize), c.TrimConfig.Func(), c.FlushPeriod) if _, err := factory.Build(); err != nil { return nil, err } diff --git a/pkg/stanza/fileconsumer/internal/splitter/multiline.go b/pkg/stanza/fileconsumer/internal/splitter/multiline.go index 07ed5c969991..8534414f787a 100644 --- a/pkg/stanza/fileconsumer/internal/splitter/multiline.go +++ b/pkg/stanza/fileconsumer/internal/splitter/multiline.go @@ -14,35 +14,35 @@ import ( "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/trim" ) -type multilineFactory struct { - multilineCfg split.Config - encoding encoding.Encoding - maxLogSize int - trimFunc trim.Func - flushPeriod time.Duration +type splitFuncFactory struct { + splitConfig split.Config + encoding encoding.Encoding + maxLogSize int + trimFunc trim.Func + flushPeriod time.Duration } -var _ Factory = (*multilineFactory)(nil) +var _ Factory = (*splitFuncFactory)(nil) -func NewMultilineFactory( - multilineCfg split.Config, +func NewSplitFuncFactory( + splitConfig split.Config, encoding encoding.Encoding, maxLogSize int, trimFunc trim.Func, flushPeriod time.Duration, ) Factory { - return &multilineFactory{ - multilineCfg: multilineCfg, - encoding: encoding, - maxLogSize: maxLogSize, - trimFunc: trimFunc, - flushPeriod: flushPeriod, + return &splitFuncFactory{ + splitConfig: splitConfig, + encoding: encoding, + maxLogSize: maxLogSize, + trimFunc: trimFunc, + flushPeriod: flushPeriod, } } // Build builds Multiline Splitter struct -func (f *multilineFactory) Build() (bufio.SplitFunc, error) { - splitFunc, err := f.multilineCfg.Func(f.encoding, false, f.maxLogSize, f.trimFunc) +func (f *splitFuncFactory) Build() (bufio.SplitFunc, error) { + splitFunc, err := f.splitConfig.Func(f.encoding, false, f.maxLogSize, f.trimFunc) if err != nil { return nil, err } diff --git a/pkg/stanza/fileconsumer/internal/splitter/multiline_test.go b/pkg/stanza/fileconsumer/internal/splitter/multiline_test.go index 10785480be23..ab758142c92c 100644 --- a/pkg/stanza/fileconsumer/internal/splitter/multiline_test.go +++ b/pkg/stanza/fileconsumer/internal/splitter/multiline_test.go @@ -15,14 +15,14 @@ import ( "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/trim" ) -func TestMultilineBuild(t *testing.T) { +func TestSplitFuncFactory(t *testing.T) { tests := []struct { - name string - multilineCfg split.Config - encoding encoding.Encoding - maxLogSize int - flushPeriod time.Duration - wantErr bool + name string + splitFunc split.Config + encoding encoding.Encoding + maxLogSize int + flushPeriod time.Duration + wantErr bool }{ { name: "default configuration", @@ -33,7 +33,7 @@ func TestMultilineBuild(t *testing.T) { }, { name: "Multiline error", - multilineCfg: split.Config{ + splitFunc: split.Config{ LineStartPattern: "START", LineEndPattern: "END", }, @@ -45,7 +45,7 @@ func TestMultilineBuild(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - factory := NewMultilineFactory(tt.multilineCfg, tt.encoding, tt.maxLogSize, trim.Nop, tt.flushPeriod) + factory := NewSplitFuncFactory(tt.splitFunc, tt.encoding, tt.maxLogSize, trim.Nop, tt.flushPeriod) got, err := factory.Build() if (err != nil) != tt.wantErr { t.Errorf("Build() error = %v, wantErr %v", err, tt.wantErr) diff --git a/pkg/stanza/fileconsumer/reader_test.go b/pkg/stanza/fileconsumer/reader_test.go index b9f59b5d8856..7f8880f9e11b 100644 --- a/pkg/stanza/fileconsumer/reader_test.go +++ b/pkg/stanza/fileconsumer/reader_test.go @@ -236,7 +236,7 @@ func testReaderFactory(t *testing.T, sCfg split.Config, maxLogSize int, flushPer emit: testEmitFunc(emitChan), }, fromBeginning: true, - splitterFactory: splitter.NewMultilineFactory(sCfg, enc, maxLogSize, trimFunc, flushPeriod), + splitterFactory: splitter.NewSplitFuncFactory(sCfg, enc, maxLogSize, trimFunc, flushPeriod), encoding: enc, }, emitChan }