diff --git a/CHANGELOG.md b/CHANGELOG.md index 63b4a6c80ae..fde36ab0912 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ ## 🛑 Breaking changes 🛑 <<<<<<< HEAD +- Rename service.Start() to Run() since it's a blocking call - Fix slice Append to accept by value the element in pdata - Change CreateTraceProcessor and CreateMetricsProcessor to use the same parameter order as receivers/logs processor and exporters. diff --git a/cmd/otelcol/main.go b/cmd/otelcol/main.go index 8cd3b51718e..f0a00053790 100644 --- a/cmd/otelcol/main.go +++ b/cmd/otelcol/main.go @@ -50,7 +50,7 @@ func runInteractive(params service.Parameters) error { return fmt.Errorf("failed to construct the application: %w", err) } - err = app.Start() + err = app.Run() if err != nil { return fmt.Errorf("application run finished with error: %w", err) } diff --git a/service/service.go b/service/service.go index 83ed4c3d0a0..50867d634be 100644 --- a/service/service.go +++ b/service/service.go @@ -458,9 +458,9 @@ func (app *Application) execute(ctx context.Context, factory ConfigFactory) erro return componenterror.CombineErrors(errs) } -// 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 { // From this point on do not show usage in case of error. app.rootCmd.SilenceUsage = true diff --git a/service/service_test.go b/service/service_test.go index a6a5e6f6706..1987e9a3c3b 100644 --- a/service/service_test.go +++ b/service/service_test.go @@ -67,7 +67,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()) }() assert.Equal(t, Starting, <-app.GetStateChannel()) @@ -120,7 +120,7 @@ func TestApplication_ReportError(t *testing.T) { appDone := make(chan struct{}) go func() { defer close(appDone) - assert.EqualError(t, app.Start(), "failed to shutdown extensions: err1") + assert.EqualError(t, app.Run(), "failed to shutdown extensions: err1") }() assert.Equal(t, Starting, <-app.GetStateChannel()) @@ -151,7 +151,7 @@ func TestApplication_StartAsGoRoutine(t *testing.T) { appDone := make(chan struct{}) go func() { defer close(appDone) - appErr := app.Start() + appErr := app.Run() if appErr != nil { err = appErr } @@ -449,7 +449,7 @@ func TestApplication_GetExtensions(t *testing.T) { appDone := make(chan struct{}) go func() { defer close(appDone) - assert.NoError(t, app.Start()) + assert.NoError(t, app.Run()) }() assert.Equal(t, Starting, <-app.GetStateChannel()) @@ -478,7 +478,7 @@ func TestApplication_GetExporters(t *testing.T) { appDone := make(chan struct{}) go func() { defer close(appDone) - assert.NoError(t, app.Start()) + assert.NoError(t, app.Run()) }() assert.Equal(t, Starting, <-app.GetStateChannel()) diff --git a/service/service_windows.go b/service/service_windows.go index 386895fa5ff..3b6f1b83d24 100644 --- a/service/service_windows.go +++ b/service/service_windows.go @@ -87,7 +87,7 @@ func (s *WindowsService) start(elog *eventlog.Log, appErrorChannel chan error) e // app.Start blocks until receiving a SIGTERM signal, so needs to be started // asynchronously, but it will exit early if an error occurs on startup - go func() { appErrorChannel <- s.app.Start() }() + go func() { appErrorChannel <- s.app.Run() }() // wait until the app is in the Running state go func() { diff --git a/testbed/testbed/otelcol_runner.go b/testbed/testbed/otelcol_runner.go index 2ea0b19791e..041ed66d447 100644 --- a/testbed/testbed/otelcol_runner.go +++ b/testbed/testbed/otelcol_runner.go @@ -120,7 +120,7 @@ func (ipp *InProcessCollector) Start(args StartParams) (receiverAddr string, err ipp.appDone = make(chan struct{}) go func() { defer close(ipp.appDone) - appErr := ipp.svc.Start() + appErr := ipp.svc.Run() if appErr != nil { err = appErr }