diff --git a/internal/exporter/export.go b/internal/exporter/export.go index e7e232a82..55bcf873b 100644 --- a/internal/exporter/export.go +++ b/internal/exporter/export.go @@ -83,13 +83,18 @@ func DisableExport() Option { } } +var ( + ErrNeedsStore = errors.New("exporter needs a Store") + ErrNeedsWaitgroup = errors.New("exporter needs a WaitGroup") +) + // New creates a new Exporter. func New(ctx context.Context, wg *sync.WaitGroup, store *metrics.Store, options ...Option) (*Exporter, error) { if store == nil { - return nil, errors.New("exporter needs a Store") + return nil, ErrNeedsStore } if wg == nil { - return nil, errors.New("exporter needs a WaitGroup") + return nil, ErrNeedsWaitgroup } e := &Exporter{ ctx: ctx, diff --git a/internal/mtail/exec_integration_test.go b/internal/mtail/exec_integration_test.go index 327fbe953..3944f74d1 100644 --- a/internal/mtail/exec_integration_test.go +++ b/internal/mtail/exec_integration_test.go @@ -31,7 +31,9 @@ func TestExecMtail(t *testing.T) { t.Skip() } - cs := []string{"-progs", "../../examples", + cs := []string{ + "-progs", + "../../examples", "-logs", "testdata/rsyncd.log", "-one_shot", "-one_shot_format=prometheus", diff --git a/internal/runtime/runtime.go b/internal/runtime/runtime.go index 1a519928d..128137b71 100644 --- a/internal/runtime/runtime.go +++ b/internal/runtime/runtime.go @@ -241,13 +241,18 @@ type Runtime struct { signalQuit chan struct{} // When closed stops the signal handler goroutine. } +var ( + ErrNeedsStore = errors.New("loader needs a store") + ErrNeedsWaitgroup = errors.New("loader needs a WaitGroup") +) + // New creates a new program loader that reads programs from programPath. func New(lines <-chan *logline.LogLine, wg *sync.WaitGroup, programPath string, store *metrics.Store, options ...Option) (*Runtime, error) { if store == nil { - return nil, errors.New("loader needs a store") + return nil, ErrNeedsStore } if wg == nil { - return nil, errors.New("loader needs a WaitGroup") + return nil, ErrNeedsWaitgroup } r := &Runtime{ ms: store, diff --git a/internal/tailer/logstream/logstream.go b/internal/tailer/logstream/logstream.go index 4bec54641..5de136fc6 100644 --- a/internal/tailer/logstream/logstream.go +++ b/internal/tailer/logstream/logstream.go @@ -46,6 +46,7 @@ var ( ErrUnsupportedURLScheme = errors.New("unsupported URL scheme") ErrUnsupportedFileType = errors.New("unsupported file type") ErrEmptySocketAddress = errors.New("socket address cannot be empty, please provide a unix domain socket filename or host:port") + ErrNeedsWaitgroup = errors.New("logstream needs a waitgroup") ) // New creates a LogStream from the file object located at the absolute path @@ -55,7 +56,7 @@ var ( // files that can be seeked. func New(ctx context.Context, wg *sync.WaitGroup, waker waker.Waker, pathname string, lines chan<- *logline.LogLine, oneShot bool) (LogStream, error) { if wg == nil { - return nil, errors.New("logstream needs a WaitGroup") + return nil, ErrNeedsWaitgroup } u, err := url.Parse(pathname) if err != nil { diff --git a/internal/tailer/tail.go b/internal/tailer/tail.go index 8f92da796..f0adba51e 100644 --- a/internal/tailer/tail.go +++ b/internal/tailer/tail.go @@ -127,7 +127,10 @@ func (opt logstreamPollWaker) apply(t *Tailer) error { return nil } -var ErrNoLinesChannel = errors.New("Tailer needs a lines channel") +var ( + ErrNoLinesChannel = errors.New("Tailer needs a lines channel") + ErrNeedsWaitgroup = errors.New("tailer needs a WaitGroup") +) // New creates a new Tailer. func New(ctx context.Context, wg *sync.WaitGroup, lines chan<- *logline.LogLine, options ...Option) (*Tailer, error) { @@ -135,7 +138,7 @@ func New(ctx context.Context, wg *sync.WaitGroup, lines chan<- *logline.LogLine, return nil, ErrNoLinesChannel } if wg == nil { - return nil, errors.New("tailer needs a WaitGroup") + return nil, ErrNeedsWaitgroup } t := &Tailer{ ctx: ctx,