Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion internal/pkg/otel/manager/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func (m *OTelManager) Run(ctx context.Context) error {
// pass the error to the errCh so the coordinator, unless it's a cancel error
if !errors.Is(err, context.Canceled) {
select {
case m.errCh <- nil:
case m.errCh <- err:
case <-ctx.Done():
}
}
Expand Down
41 changes: 41 additions & 0 deletions internal/pkg/otel/manager/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,3 +183,44 @@ func TestOTelManager_Run(t *testing.T) {
t.Errorf("otel manager returned unexpected error: %v", runErr)
}
}

func TestOTelManager_ConfigError(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
l, _ := loggertest.New("otel")
m := NewOTelManager(l)

go func() {
err := m.Run(ctx)
require.ErrorIs(t, err, context.Canceled, "otel manager should be cancelled")
}()

// watch is synchronous, so we need to read from it to avoid blocking the manager
go func() {
for {
select {
case <-m.Watch():
case <-ctx.Done():
return
}
}
}()

cfg := confmap.New() // invalid config
m.Update(cfg)
timeoutCh := time.After(time.Second * 5)
var err error
outer:
for {
select {
case e := <-m.Errors():
if e != nil {
err = e
break outer
}
case <-timeoutCh:
break outer
}
}
assert.Error(t, err, "otel manager should have returned an error")
}