diff --git a/cmd/otelcol/main.go b/cmd/otelcol/main.go index 66720c45078..a37c47109a5 100644 --- a/cmd/otelcol/main.go +++ b/cmd/otelcol/main.go @@ -44,6 +44,6 @@ func main() { svc, err := service.New(factories, info) handleErr(err) - err = svc.Start() + err = svc.Run() handleErr(err) } diff --git a/service/service.go b/service/service.go index 906ff0d7fe9..63d8549ce53 100644 --- a/service/service.go +++ b/service/service.go @@ -375,9 +375,9 @@ func (app *Application) execute() { app.logger.Info("Shutdown complete.") } -// Start starts the collector according to the command and configuration -// given by the user. -func (app *Application) Start() error { +// Run starts the collector according to the command and configuration +// given by the user, and waits for it to complete. +func (app *Application) Run() error { return app.rootCmd.Execute() } diff --git a/service/service_test.go b/service/service_test.go index 37b5f426458..4632941c2b3 100644 --- a/service/service_test.go +++ b/service/service_test.go @@ -54,7 +54,7 @@ func TestApplication_Start(t *testing.T) { appDone := make(chan struct{}) go func() { defer close(appDone) - assert.NoError(t, app.Start()) + assert.NoError(t, app.Run()) }() <-app.readyChan